1847712 Members
4849 Online
110265 Solutions
New Discussion

Re: VI and EX command

 
SOLVED
Go to solution
James Odak
Valued Contributor

VI and EX command

ok this is driving me nuts, i know i've done this before

lets say i have a file and via the vi editor i want to, with one command delete the 24th character in each line

i keep thinking it should be

:1,$ g// 24lx
or something to that effect ..
what am i forgetting or doing wrong?

thanks
Jim
2 REPLIES 2
Rodney Hills
Honored Contributor
Solution

Re: VI and EX command

Well 24l is a motion command and can't be executed by "g".

You could do the following-
:set magic
:1,$s/^\(.\{23,23\}\)\(.\)/\1/

The "cut" command could also be used.

Usually when somewhat complicated edits need to be done, I prefer "perl" or sometimes "awk".

HTH

-- Rod Hills
There be dragons...
James Odak
Valued Contributor

Re: VI and EX command

yikes that looks familiar but worse .. i was making it harder then needed, cut -c works just as well thanks