开发者

vim "autoindent" // pattern

开发者 https://www.devze.com 2022-12-26 14:22 出处:网络
My terminal is 160 characters wide. I use VIM. Is there a way to tell vim: when you see \"//\", autoindent it to start @ width 80?

My terminal is 160 characters wide.

I use VIM.

Is there a way to tell vim:

when you see "//", autoindent it to start @ width 80?

(And haave it also affected when I highlight a reg开发者_Python百科ion and hit =)

Thanks!


Set the following line in your .vimrc file.

set autoindent

set textwidth=80


You might want to see about :filetype indent plugin on

You may also want to look at this plugin: 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>
0

精彩评论

暂无评论...
验证码 换一张
取 消