As I am still relatively new to vim, if there is a better alternative or if there are improvements to be made, please do let me know.
Setup
The solution I ended up with makes use of a regular expression that is saved to a separate regex.vim
file, which is sourced in init.vim
. The full explanation can be found here:
init.vim
" Regular expressions
source ~/.config/nvim/regex.vim
regex.vim
" Inserts a thousand separator after \0
let sep = 's/\d\(\%\(\d\{3\}\)\+\(\d\)\@!\)\@=/\0'
Source the added regex.vim
before continuing.
Usage
Upon visually selecting a number or multiple numbers with v, press : to enter Command-line mode.
Press Ctrl + r, followed by = to allow for an expression to be entered. Type the name that you gave to the regular expression in regex.vim
, e.g. sep
and press Enter.
As displayed below, entering any character after the above operation should add it as the separator.
