分页: 1 / 1

VI中替换换行符

发表于 : 2007-11-29 10:24
yuffey
Windows files has line feed and carriage return. When such files are copied to *nix like OS, vim / vi shows ^M characters at the end of each line.

To get rid of those ^M use:

代码: 全选

1,$ s/^M//gc
or
% s/^M//gc

To type ^M hit ctrl+v first and then M.
Anonymous, January 31, 2007 14:11

代码: 全选

For ^M hit CTL-v then CTL-M or CTL-v enter
Anonymous, January 31, 2007 14:24
one of the oldest topics ever, see vimtip #26

Anonymous, January 31, 2007 23:28
Note that, for people using Vim with Windows keybindings, CTRL-V is (naturally) the paste operation;
so, to produce a

代码: 全选

 ^M, you have to type CTRL-Q then CTRL-M