I would like to have a marker at column 80 in VIM, but only in file like *.cpp, *.h. but not in *.txt
For now I have this in my .vimrc
set cc=120
Cheers
Solution:
autocmd FileType cpp,c,cxx,h,hpp,python,sh setlocal cc=120
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Vim doesn’t directly use the file extension, it has an indirection called
filetype, which is then used for syntax highlighting and specific settings.Put your
:setcommand (as:setlocal, so that it only affects the current buffer [1]) in a new file~/.vim/after/ftplugin/cpp.vim. (You could also use:autocmd FileType cpp setlocal cc=120directly in your.vimrc, but the separation is cleaner once you do a lot of that customization.)[1] Note that
'colorcolumn'is window-local, not buffer-local, so the approach isn’t perfect, but usually good enough. It can be perfected with additionalBufWinEnter/Leaveautocmds.