Inspired by vimtips.
Replace all date in format YYYYMMDD
to MM/DD/YYYY
:
%s/\(20\d\{2}\)\(\d\{2}\)\(\d\{2}\)/\2\/\3\/\1/g
:%s/(.*)//g
E.g. on the following file:
Charlax <toaster@toasting.org>
Execute:
:%s/.*<//g
:%s/>//g
E.g.:
* Toaster: 1
* Toaster: 2
To delete everything after :
:
:%s/:.*//
:%s/<Ctrl-V><Ctrl-M>/\r/g
This is a good example of a complex regex which uses \=
to trigger vim
command execution.
%s%^\(#\+.*\)$%\=submatch(1).' (id::'.substitute(system('LC_ALL=C tr -cd "[:alnum:]" < /dev/urandom | fold -w15 | head -n1'), '\n','','g').')'%g
It will transform:
# Test
Into:
# Test (id::nYgp7segfLWXeWM)