I usually have to read .txt files with long lines, and at the same time edit some source file, and I like to see word wrap on the .txt files, and not in the ones that aren't.
Of course I can :set wrap and :set linebreak, but is there any way to make it automatucally, and dependent of the file extension?
you can do lot more with autocommand, refer here: http://www.thegeekstuff.com/2008/12/vi-and-vim-autocommand-3-steps-to-add-custom-header-to-your-file/
There are two options that I can think of. Firstly, you can use an autocmd as suggested by Tassos:
See:
An alternative (that is probably more applicable if you've got multiple settings as you have suggested): create a file in the
after/ftplugin
directory of your vim configuration folder (see below) calledtxt.vim
and it will be sourced whenever you open a.txt
file. You can put it in the plainftplugin
directory (rather thanafter/ftplugin
), but it any built-in settings for.txt
files will then not be loaded.Put any commands you want in this file:
See:
Vim Configuration Folder
On Windows this would typically be something like:
(I think), or
or even:
On Linux, it is:
For more info, see:
I guess
:autocmd BufNewFile,BufRead *.txt set wrap
should do the trick