简体   繁体   English

vim“autoindent”//模式

[英]vim “autoindent” // pattern

My terminal is 160 characters wide. 我的终端是160个字符宽。

I use VIM. 我用VIM。

Is there a way to tell vim: 有没有办法告诉vim:

when you see "//", autoindent it to start @ width 80? 当你看到“//”时,自动启动@宽度80?

(And haave it also affected when I highlight a region and hit =) (当我突出显示一个区域并点击=时,它也会受到影响)

Thanks! 谢谢!

Set the following line in your .vimrc file. 在.vimrc文件中设置以下行。

set autoindent 设置自动注册

set textwidth=80 设置textwidth = 80

You might want to see about :filetype indent plugin on 您可能希望看到:filetype indent plugin on

You may also want to look at this plugin: http://www.vim.org/scripts/script.php?script_id=294 您可能还想查看此插件: http//www.vim.org/scripts/script.php? script_id = 294

Generally, it sounds like a bad idea to arbitrarily indent comments that far in. Usually comments should be on the same indentation as the code, or just after the code if it is on the same line. 一般来说,任意缩进远远的注释听起来是个坏主意。通常注释应该与代码在同一个缩进上,或者只是在代码之后,如果它在同一行上。

If you're really sure this is what you want to do, you could make a mapping or an abreviation: 如果您确定这是您想要做的,您可以进行映射或缩减:

:iab // <ctrl-o>80i<space><esc>A//<space>

or 要么

:imap // <ctrl-o>80i<space><esc>A//<space>

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

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