Nikolaos A. Patsopoulos wrote:
Hi,
is there a way to yank in ex-mode? I want to find all \d\d\d\d in
my file and put them in the end of their containing line.
Thanks in advance,
Nikos
That looks like stuff for a substitute:
a) if the pattern appears at most once per line:
:1,$s/^\(.\{-}\)\(\d\d\d\d \)(.*\)$/\1\3\2
b) if the pattern can appear any number of times per line:
" *** UNTESTED ***
" clobbers register x
function Rearrange()
let @x = ""
normal 0
while search('\d\d\d\d ', 'c', line('.') != 0
" delete the 10 characters of the match
" and append to register x
normal "X10x
endwhile
" paste at the end of the lline
normal $"xp
endfunction
1,$g/\d\d\d\d /call Rearrange()
Notes:
- You can do anything in ex-mode, see ":help :normal"
- To yank linewise, see also
* :help :yank
* :help getline()
Best regards,
Tony.