On 11/07/11 13:07, Totte Karlsson wrote:
Say I have lines looking like this
[1
[2
[3
and want to add the missing ] at the end of the line.
What is the command for that? Should one use search and replace or something
else?
It depends on whether you need to manually tweak each line or if
the change can be automated. In your case, you can do things like
:%s/\[\d\+]\@!\zs/]/g
"where there's an open-bracket, one or more digits and no closing
brace, start replacing at the end of the match and replace with a
close-bracket" This one is pretty tight and should skip cases
where there's already a close-bracket
2) :g/\[\d/s/$/]
"on lines containing an open-bracket followed by digits, put a
']' at the end of the line"
3) if they're contiguous, visually select the lines in
block-mode, press "$" followed by "A" (append some text after
each line), "]" (the text you want to append) and <esc> (to exit
insert-mode)
4) you can search for the text, placing the cursor at the end and
use "n" and "." to append the text:
/\[\d\+/e
a]<esc>
n.n.n.n.n.n. (as needed)
There are plenty of other options, but that should get you some
starting options :)
-tim
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php