vim - Creating multiple .vimrc for multiple languages? -
i starting learn programming , saw possible configure vim through .vimrc file. i'm having trouble creating more 1 setting. want configuration java , c, not know how enable configuration when programming in particular language.
i found following solution problem:
if it's okay configure local exceptions centrally, can put such
autocmds~/.vimrc:
:autocmd bufread,bufnewfile /path/to/dir/* setlocal ts=4 sw=4(how load different .vimrc file different working directory?)
but did not understand solution.
i figured should following:
i wanted create c language setting on desktop. put in shell (i'm using mac os) following command
vim ~/desktop/.vimrc, put desired configuration in file.then put following command in file
~/.vimrc:autocmd bufread,bufnewfile ~/desktop/.vimrc setlocal ts=4 sw=4then went shell , created c file
vim ~/desktop/myprogram.c, realized setup had not worked.
obviously did wrong, not find error, because i'm still noob.
for need 3 files: ~/.vimrc , 2 scripts let's c-settings.vim , java-settings.vim
in first file, ~/.vimrc, need include these autocommands:
"to enable file type detection" filetype on augroup java_c_settings "the command below execute script specific filetype c autocmd filetype c source /path-for-c-settings/c-settings.vim "the command below execute script specific filetype java autocmd filetype java source /path-for-java-settings/java-settings.vim augroup end in other files (c-settings.vim & java-settings.vim) put settings need every type of file *.c , *.java
example:
c-settings.vim
set number colorscheme blue java-settings.vim
set number colorscheme evening whenever open file vim latter check filetype first , settings automatically configured.
note: if setting files not in same directory can rename them .exrc.
Comments
Post a Comment