简体   繁体   中英

vim “autoindent” // pattern

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 region 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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