On 11/11/10 03:09, Ryan J M wrote:
Hi there,
I mapped a short key for command ":s/\s\+/^M/g" in .vimrc
(^M was typed using C-V,C-M), but the short key doesn't work as
expected.
Can someone share some suggestions?
^M (or \r ), i.e., the <Enter> key, behaves specially in substitutes:
- You can match a ^M (but not a linebreak) by using \r (or by ^M entered
by hitting ^V followed by ^M or by Enter). \n matches a linebreak.
- In the "replace-by" part, \r (or ^M) breaks the line: so the above
subsitute should (IIUC) replace (greedily) any sequence of one or more
tabs and spaces in the current line by a linebreak.
see ":help s-<CR>" which is part of ":help sub-replace-special"
- To insert a "raw" control-M without breaking the line, prefix it with
a backslash.
- To replace a linebreak by itself, use :s/\n/\r/ -- it may look weird,
but that's how it works.
Note that Vim uses the ASCII convention for its control-keys:
- Ctrl+? is 0x7F
- If 0x40 <= x <= 0x5F (including uppercase letters [A-Z]), Ctrl+x is (x
- 0x40)
- If x is a lowercase letter [a-z], Ctrl+x is the same as Ctrl+ upcase(x)
- No other Ctrl + printable key works reliably: in most cases Vim will
either not get the key at all, or not get the Ctrl modifier. (Ctrl +
non-printable key, such as Ctrl-F5 or Ctrl-Home, is handled differently,
but some of them may be snatched by the OS, the window manager, or (in
console mode) the console before Vim has a chance to see them.)
Best regards,
Tony.
--
A village. Sound of chanting of Latin canon, punctuated by short, sharp
cracks. It comes nearer. We see it is a line of MONKS ala SEVENTH SEAL
flagellation scene, chanting and banging themselves on the foreheads
with
wooden boards.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
--
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