sponsor Vim development Vim logo Vim Book Ad

uke164.vim : Convert UK phone numbers to E.164 (+44) and back to 07xxx format

 script karma  Rating 0/0, Downloaded by 3  Comments, bugs, improvements  Vim wiki

created by
CryptoeSIM Notes
 
script type
utility
 
description
Two commands for cleaning up UK phone numbers in CSV exports, contact lists, test fixtures and config files.

:UkToE164 rewrites loosely typed UK numbers into E.164, the format most SMS gateways, Twilio-style APIs and sign-up forms expect:

  07700 900123            ->  +447700900123
  (07700) 900-123         ->  +447700900123
  0044 7700 900456        ->  +447700900456
  +44 (0)20 7946 0018     ->  +442079460018

:UkToNational does the reverse for documents people actually read:

  +447700900789  ->  07700 900789
  +442079460018  ->  020 7946 0018

Both take a range, so :%UkToE164 fixes a whole file and a visual selection works too. Only things that look like a UK number are changed: a leading 0 plus ten digits, or a +44 / 0044 prefix. Order numbers, dates and longer digit runs are left alone. The stray "(0)" people write after +44 is removed, because +440... is invalid and is one of the most common reasons a verification text never arrives.

What it does not do: it does not check that a number is in service, and it cannot tell a real mobile line from a VoIP number that has been given a 07 prefix. That matters if you are entering a number for SMS verification, since many apps look up the line type and refuse VoIP ranges even when the format is perfect. If that is your situation, there is a plain-English explainer on renting a non-VoIP UK number for SMS verification (+44 7 format, paid in crypto) at https://cryptoesim.io/phone-numbers and the Ofcom numbering plan is the authority on which prefixes are mobile.

Tested on Vim 9.2. MIT licence.
 
install details
Copy uke164.vim into ~/.vim/plugin/ ($HOME/vimfiles/plugin on Windows) and restart Vim, or run :source uke164.vim. Then use :UkToE164 or :UkToNational on a line, a range (:%UkToE164) or a visual selection.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
uke164.vim 1.0 2026-11-19 7.4 CryptoeSIM Notes Initial upload
ip used for rating: 216.73.217.19

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github