I've looked at this but it wasn't too much help. Maybe I didn't read it too well.
Basically what I want is when I open a .txt file the settings:
set wrap set linebreak
are turned on. How might I go about doing that?
Thanks in advance.
Also, I'm using XP.
As other answers have mentioned, you can use the vim set command to set syntax. :set syntax=<type> where <type> is something like perl , html , php , etc. There is another mechanism that can be used to control syntax highlighting called filetype , or ft for short.
Settings file used by Vim, a text editing program often used by source code developers and system administrators; saves the default settings for the editor when it is opened; allows users to customize options for the editor. VIMRC files are saved in a plain text format.
$HOME\vimfiles\filetype. vim (Windows systems)
My answer to that question still applies:
Put autocmd commands based on the file suffix in your ~/.vimrc
autocmd BufRead,BufNewFile *.txt set wrap linebreak
As Luc says, you might prefer to
autocmd BufRead,BufNewFile *.txt setlocal wrap linebreak
if you're likely to open txt and non-txt files at the same time.
Put this into ~/.vim/ftdetect/text.vim (this path will be slightly different on windows):
autocmd BufRead,BufNewFile *.txt setfiletype text
Then put this into ~/.vim/ftplugin/text.vim:
setlocal wrap setlocal linebreak
It's preferable to only do the autocmd once for a filetype, and to separate it from your vimrc file.
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