say that i have a project which lies in a folder called 'bin', and i want some specific vim configuration automatically loaded when i edit any file inside the project folder. how can i do that?
The user vimrc file often does not exist until created by the user. If you cannot find $HOME/. vimrc (or $HOME/_vimrc on Windows) then you can, and probably should, just create it. The system vimrc should normally be left unmodified and is located in the $VIM * directory.
A VIMRC file is a settings file used by the Vim text editor.
To source vimrc in all buffers in the current window I do :bufdo so~/. vimrc ,to source vimrc in the ACTIVE buffers in all windows I do :windo so~/. vimrc .
I think what you want is an autocommand. Perhaps something like this:
autocmd BufRead,BufNewFile ~/bin/* call SetBinOptions()
function SetBinOptions() {
setlocal number
setlocal nowrap
...
}
If you need to do something complex with the path matching, you can take a slightly different approach, making the decision about whether to apply the options within the function. Suppose you had some regex the path had to match:
autocmd BufRead,BufNewFile * call SetCustomOptions()
function SetCustomOptions() {
if (match(expand("%:p"), /regex/) {
setlocal number
setlocal nowrap
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With