I am starting to learn programming and saw that it is possible to configure vim through the .vimrc file. But I'm having trouble creating more than one setting. I want a configuration for java and another for C, but I do not know how to only enable a configuration when programming in a particular language.
I found the following solution to my problem:
If it's okay to configure the local exceptions centrally, you can put such
autocmd
s into your~/.vimrc
:
:autocmd BufRead,BufNewFile /path/to/dir/* setlocal ts=4 sw=4
(How to load different .vimrc file for different working directory?)
But I did not understand that solution.
I figured I should do the following:
I wanted to create a C language setting on the Desktop. So I put in Shell (I'm using Mac OS) the following command
vim ~/Desktop/.vimrc
and put the desired configuration in this file.Then I put the following command in the file
~/.vimrc
:autocmd BufRead,BufNewFile ~/Desktop/.vimrc setlocal ts=4 sw=4
Then I went into the Shell and created a C file
vim ~/Desktop/myprogram.c
, but I realized that my setup had not worked.
Obviously I did something wrong, but I could not find the error, because I'm still noob.