Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I split long lines in a .vimrc file?

Tags:

vim

I've got a line in my .vimrc that is more than 80 chars long:

autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with 

I find this rather annoying, so I want to break it into multiple lines, but I don't know how to do that. I tried \ since that does the trick in Python and the Bourne shell, but apparently that's not valid syntax in Vim:

autocmd FileType python set smartindent \     cinwords=if,elif,else,for,while,try,except,finally,def,class,with 

gives

E492: Not an editor command 

Can anyone tell me how to split this line?

(Bonus points if someone can tell me how to add to cinwords instead of resetting it entirely; the only thing I wanted to achieve is add the with keyword to it.)

like image 282
Fred Foo Avatar asked May 31 '12 10:05

Fred Foo


People also ask

How do I split a line in Vim?

Show activity on this post. then just press Ctrl-J whenever you want to split a line.

How do I edit a Vimrc file?

Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.

How do I create a .vimrc file in Windows?

Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so ). The only file sourced by default is the . vimrc ( _vimrc on windows) so that's a place you can keep all the commands you use to set up Vim every time.


1 Answers

Hit :help line-continuation.

Basically you have to add \ at the beginning of the continued line.

So instead of writing

autocmd FileType python set smartindent \     cinwords=if,elif,else,for,while,try,except,finally,def,class,with 

you have to write

autocmd FileType python set smartindent        \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with 
like image 90
shime Avatar answered Sep 30 '22 15:09

shime