I am new user to gVim and i love this tool. Currently i am trying to
replace all the columns except the last one with blank.
How can i achieve this in vim? I don't want to redirect the output to
new file i am using this as a notepad replacement.
-rw-r--r-- 1 oracle dba 199 Jun 26 2007 temp.lst
-rw-r--r-- 1 oracle dba 289093 Jun 26 2007 abcd.lst
-rw-r--r-- 1 oracle dba 128368 Sep 22 2007 138.lst
-rw-r--r-- 1 oracle dba 128368 Sep 30 2007 133.lst
-rw-r--r-- 1 oracle dba 145893 Dec 31 2007 149.lst
-rw-r--r-- 1 oracle dba 145893 Dec 31 2007 149_1.st
The end result should be like
temp.lst
abcd.lst
139.lst
133.lst
149.lst
149_1.lst
Thanks for your help.
Regards,
Nagendra Chillale
:%s/.* //
where
% -- for every line
s/.* // -- replace all characters including the last space
with nothing
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
Hi Glen,
temp.lst
abcd.lst
138.lst
133.lst
149.lst
This is the result i get, what i see missing is the last rows from the
column (149_1.lst)
Regards,
Nagendra Chillale
Hi Gerard,
Yes that solved it. I din't read well or understand right Glen's
explanation of s/.* // -- replace all characters including the last
space with nothing.
But yes on the last line of -rw-r--r-- 1 oracle dba
145893 Dec 31 2007 149_1.st had a space and hence it was not showing
149_1.lst
Thanks Glen & Gerard appreciate your help.
Regards,
Nagendra Chillale
Alternatively, vim has a "block select" mode: ctrl-V, so you could
select the rectangle you want to delete and hit 'x'
Hi Glen,
Unfortunately in gVim (While in visual mode) ctrl-V result in pasting
of data in the clipboard if thats what it uses to paste.
Regards,
Nagendra Chillale
Gvim / Windows can do block select / delete:
1) Right click on one "corner" of the block
2) in the drop down that appears, select "Select Block"
3) move cursor to the diagonal corner using the keyboard (NOT the
arrow keys)
h = left, j = down, k = up, l = right. The area should highlight
as the cursor moves
4) hit "delete key" or "x" to remove
Hi Glen,
I did figure out a way to select in block select mode in gVim. On
right clicking in gVim you get several options, one of 'em is "Select
Block" chose this. Now hold the shift key and select the rectangle and
just delete.
Regards,
Nagendra Chillale
Hi Scott,
Yeah your exact steps is how i got it worked out. But before you could
reply :), thank you so much for the reply.
Regards,
Nagendra Chillale