How to automatically execute a VIM command only for some file types
Posted: maggio 21st, 2012 | Author: Francesco Apollonio | Filed under: English, Guide, Howto | Tags: config, Guide, latex, linux, program, utility, vim | No Comments »
I want to set the maximum line length to a certain value, only for tex files.
VIM has a command to force line length. It’s:
set tw=120
To automatically execute this command only for tex files, you have to edit your vimrc file (~/.vimrc or /etc/vim/vimrc) adding the following lines:
if has("autocmd")
autocmd BufRead,BufNewFile *.tex set tw=120
endif
Now VIM will execute this command every time that you will open a tex file.








Leave a Reply