In my .vimrc I have the following line:
set textwidth=80
However, when editing the files: README-SETUP and README-INSTALL I would like vim to have textwidth set to 60.
I think this can be done for specific file types using autocmd, but how would I do it for specific files?
You could do this like so:
autocmd BufReadPre README*.txt setlocal textwidth=60
Or you could list the files one by one:
autocmd BufReadPre README-SETUP setlocal textwidth=60
autocmd BufReadPre README-INSTALL setlocal textwidth=60
EDIT: As ZyX points out, prefer setlocal over set for options like this you really don't want all buffers having that textwidth for the duration of the session.
You can also add a comment to the top of the file:
# vim: textwidth=80
You can replace the # by whatever character signifies a comment in your context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With