简体   繁体   English

如何有效地使用VIM编辑英文文本?

[英]How do I use VIM effectively for editing English text?

As a programmer by heart, if not by profession, I increasingly rely on, nay live in VIM for most editing-related tasks. 作为一名程序员,如果不是专业人士,我会越来越依赖,而不是生活在VIM中进行大多数与编辑相关的任务。 What tips can you offer for using (almost) everyone's favorite editor for editing general-purpose text, say, an article? 您可以提供哪些技巧(几乎)每个人最喜欢的编辑器来编辑通用文本,比如一篇文章? I mean plain text, with minimal markup using Markdown or RST ; 我的意思是纯文本,使用MarkdownRST进行最少的标记; I'm not looking for support for LaTeX or for entering mathematical formulae. 我不是在寻找对LaTeX或输入数学公式的支持。

I enable soft-wrapping when I'm editing most text files: 我在编辑大多数文本文件时启用了软包装:

:set wrap

If you decide to do the same, then you'll want to know about gj and gk in normal mode, to move by screen lines instead of physical lines. 如果您决定这样做,那么您将希望在正常模式下了解gjgk ,通过屏幕线而不是物理线移动。 I use them so often I remapped the up and down arrow keys to them instead of k and j . 我经常使用它们,我将上下箭头键重新映射到它们而不是kj

Whether you're editing hard- or soft-wrapped files, you'll get a lot of mileage out of gqap (or its cousin gwap ) to re-wrap a single paragraph with hard newlines, and vipJ to join all the lines of a hard-wrapped paragraph back into a single line. 无论你是编辑硬包装文件还是软包装文件,你都会从gqap (或它的堂兄gwap )中获得很多里程,用硬换行重新包装一个段落,并使用vipJ加入所有行硬包装段落回单行。

You might also want to consider including a in formatoptions , to enable automatic paragraph formatting: 您可能还需要考虑,包括aformatoptions ,启用自动段落格式:

:set formatoptions+=a

When you're doing all this wrapping and unwrapping, it's nice to keep Vim from mangling numbered lists: 当你正在进行所有这些包装和展开时,让Vim不受编号列表的影响是很好的:

:set formatoptions+=n

In fact, I'd suggest reviewing all the formatoptions and adjusting them to your particular preferences: 事实上,我建议您查看所有formatoptions选项并根据您的特定偏好进行调整:

:help fo-table

More info: 更多信息:

:help gj
:help gk
:help gqap
:help auto-format
:help formatoptions

Spell checking: 拼写检查:

:setlocal spell spelllang=en_us
" ]s moves to the next mispelled word
" [s moves to the previous mispelled word

It's not very well maintained, but the Vim-Outliner project makes Vim into a killer outliner for plain text writing. 它维护得不是很好,但Vim-Outliner项目使Vim成为纯文本写作的杀手大纲。 You can download v0.34 here (there's a more recent version, I think, but I'm not sure where to get it): 你可以在这里下载v0.34(我认为这是一个更新的版本,但我不知道从哪里得到它):

http://www.vimoutliner.org/postnuke-phoenix-0.7.2.3/html/modules.php?op=modload&name=Downloads&file=index&req=viewdownload&cid=4 http://www.vimoutliner.org/postnuke-phoenix-0.7.2.3/html/modules.php?op=modload&name=Downloads&file=index&req=viewdownload&cid=4

I really enjoyed this blogpost about writing better with latex. 我非常喜欢这篇关于用乳胶写得更好的博文。 You could use vim-latex :) It's more about writing better, than just editing english text though. 你可以使用vim-latex :)它更多的是写作更好,而不仅仅是编辑英文文本。

http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/ http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/

Use insert abbreviations: 使用插入缩写:

iabbr teh the
iabbr i I
iabbr definately definitely

Edit, another tip: 编辑,另一个提示:

set wrap nolist linebreak

This tells vim to wrap lines that are too long with "visual" newlines rather than adding an actual newline character to the file. 这告诉vim用“可视”换行包装太长的行,而不是在文件中添加实际的换行符。 The 'list' option must be off because it automatically disables the 'linebreak' option. 'list'选项必须关闭,因为它会自动禁用'linebreak'选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM