tags:

views:

65

answers:

2

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!

+3  A: 

Set the following line in your .vimrc file.

set autoindent

set textwidth=80

ungalnanban
I don't claim to know a lot about .vimrc files, but I can't imagine how that will answer the question since it doesn't even do any sort of pattern search for "//". Can you explain how this works for a user like me who's still learning?
Platinum Azure
That is probably NOT what you want. It has nothing to do with aligning anything.
Kimball Robinson
He was probably meaning to say "set tabstop=80" but you *really* don't want that either.
Kimball Robinson
A: 

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>
Kimball Robinson