Hello,
I would like to add a "c" (c character) at the beginning of a line (or
of a range) for any character already present at column 1. This means
that if "c" is the first character of the line, I want to get "cc". If
it is "a", I want to get "ca".
Using
:s/a*/c/
works because * can be zero so that *a can be an empty string.
Unfortunately, if "a" is the first character of the line, the command
results in c replacing a (not inserting before a).
Is there a way to solve this problem, for example by representing an
empty string in an absolute manner.
I tried /.*/ but it replaces the whole line.
I tried // but it represents the last search string.
I'm not exactly sure what you're looking for, but perhaps this does the
trick?
:s/^\(\a\)/c\1/
Search for the start of the line followed by anything that matches a
character. Then substitute that for 'c' followed by whatever character
matched the search.
James
--
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