English 中文(简体)
• 如何在Vim编辑一个文件,所有线在^M结束,但最后线在^M^J结束
原标题:How to edit a file in Vim with all lines ending in ^M except the last line ending in ^M^J
  • 时间:2010-12-30 11:41:54
  •  标签:
  • vim

我需要查阅大量档案。 这些档案中的所有线均在^M(x0D)中结束,但^M^J(x0Dx0A)的最后一行除外。

Obviously, Vim determines the filetype to be DOS with the effect that the file s entire content is displayed on one single line like so:

some text foo^Mmore text and^Ma few control-m^Ms and more and more

Since I don t want to change the files content: is there a setting in Vim that allows to look at these files with the new lines as I d expect them to be?

最佳回答

如果您不认为底部有一条线,包含一个<条码>。 您可制定<代码>fileformats(注s at the end)至mac,并重载缓冲:

:set fileformats=mac
:edit

或者,同样,你可以开始编辑如下:

vim -R "+set fileformats=mac" "+edit" <filename>

<代码>-R(现成)的备选办法是这样,因为你表示不想改变档案。

我没有找到不涉及重载缓冲的办法。

问题回答

为此:

:set fileformat=unix

确实可以核实,因为我没有这种档案。





相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签