Start vim without vimrc / change vimrc with open files

I have .vimrc ~/.vimrc and ~/.vimsqlrc configuration files.

Is there a way that I can fix any of them (switch from one to another) while I have some files that are already open? As an extension, how do I disable vimrc download (i.e. do not use vimrc) while I have files?

+7
vim
source share
1 answer

Your ~/.vimrc is read and executed only once. If you want to nullify it with another file, you will have to change the value of each individual option and unmount each individual display, in particular, both files. This sounds like a very bad and overly complicated idea.

If you want a different environment, just use a different environment:

 $ vim <-- starts Vim normally, reading ~/.vimrc $ vim -u ~/.vimsqlrc <-- starts Vim using your alternative vimrc $ vim -u NONE <-- starts Vim without any vimrc $ vim -u NORC <-- starts Vim without any vimrc, but with plugins 

but I'm afraid you will have to stop and restart Vim for this.

Anyway, your question has a very strong XY problem . Do you want to have specific settings for *.sql files?

If your goal is, you can put your settings in ~/.vim/after/ftplugin/sql.vim as follows:

 setlocal autoindent nnoremap <buffer> <F6> :echo "F6"<CR> 

Using setlocal for parameters and <buffer> for mappings ensures that your settings apply only to *.sql files.

+27
source share

All Articles