I know how to remove ^M
in my files (%s/^M//g
), but this one is just one line I'd like to replace ^M
with enter... what's the enter character in VIM (to use in commnad-line mode).
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
- How to copy the value of a vim option to a registe
- E185: Cannot find color scheme*
- How do I fix vim to properly indent folds containi
In vim session try:
Where
^M
is achieved byctrl+V+M
keystrokes together.To replace carriage return character (which is
<C-m>
) with line feed character (which is unix line break character) you should run a bit strange command:It looks like if it is doing nothing, but in regular expressions and double-quoted strings carriage returns are represented using
\r
and line feeds with\n
, while in the replacement part of :s command and substitute() function they mean the opposite.Note that in terminal Enter produces
<C-m>
, so your initial request is not valid.You can replace one character using
r<CR>
in normal mode.Or you can enter a "return" in command line mode by typing
<C-v><CR>
.:%s/\r//g
only works when:set ff=unix
, which when done, automatically converts allCRLF
toLF
set ff=dos
andCR
is a rogue char that is not preceded by LF, e.g., inserted withC-V C-M
.CR in LF CR pairs will not be found.
Therefore, if all you want is to convert every
LF CR
toLF
, you should use:Similar to @ZyX and @anubhava, but assuming you're simply trying to remove the pesky carriage returns from a windows file, the following will suffice: