2

This question already has an answer here:

I used set colorcolumn=80 and set the color to red in the python.vim file. Works like a champ - even for all other files.

I'd also like to set colorcolumn=110 for C files though; this one has been set to darkgray for color separation.

It seems the order of loading is the problem; if python.vim loads last, its column and color are used; if clang.vim is loaded last, then it stomps the python.vim.

Turning the dial back, I've been diddling with my own tailored vim setup for quite a while now. I clearly got a little carried away with the modularity; that notwithstanding:

Within the existing context, how would one make this change so it's language specific?

marked as duplicate by EvergreenTree, muru Sep 7 '15 at 6:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

the standard way to do this is to create autocommands groups:

augroup python
    au! " clear augroup when reloading vimrc
    autocmd FileType python set colorcolumn=80
augroup END

augroup cc
    au! " clear augroup when reloading vimrc
    autocmd FileType c,cpp set colorcolumn=110
augroup END

is a way to execute specific commands for a given filetype.

But as you want to source specific files given a filetype, then you should use:

~/.vim/ftplugin/python.vim
~/.vim/ftplugin/clang.vim

to load your personal commands.

  • If you do appreciate my help, you can accept my answer and vote it up ;-) otherwise you're welcome! – zmo Sep 8 '15 at 8:04
  • Accepted! I attempted to vote it up but there are restrictions for newbs; gotta get 15 rep before I can vote, sorry man. – todd_dsm Sep 8 '15 at 18:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.