Options can be global, window-local, or buffer-local.
When you :set a global option, the new value is global.
When you :setlocal a global option, the new value is local.
When you :set a local option, the new value is local.
softtabstop being a buffer-local option, changing its value only affects the current buffer.
The "scope" of an option is indicated ...
Is it a matter of source-ing the file as I am editing it?
Yes! :so % should do the trick when you're editing your vimrc. Or you can also use the special variable $MYVIMRC to access it from anywhere. I have a mapping like the following:
nnoremap <F5> :source $MYVIMRC<CR>
There are a few things you need to do to your vimrc to make sure ...
You can use :let with Vim options as well, by prefixing the option name with a & sigil; cp. :help :let-option
let &tags = getcwd().'\tags'
Note that the literal string must be in single quotes (or the backslash doubled); else, the \t will expand to a tab character.
The other way would be by using :execute, but then you'd have to take care of ...
Is there any advantages or side-effects of an explicit set nocompatible that I'm perhaps missing?
Actually, there are many side-effects. Every time compatible is set or reset Vim rescans all options (except "terminal") and switches defaults when necessary. After that it rebuilds quite a few internal tables for iskeyword, spelling, vartabs etc. (see ...
I'd personally recommend against doing so, but you can use Vim's "line continuation" feature for this:
This will be interpreted by Vim as if the contents of the lines after the backslashes were written at the end of the previous line:
set number showmatch hlsearch
Note that whitespace before the backslash is ...
:tabdo windo set number gets the job done, but I don't really like it since it actually switches to each tab and window before running the command. After it finishes running, you'll end up on the last window of the last tab.
I think this is a cleaner way to set options in all windows without changing the current tab and window:
function! s:set_all(option, ...
One reason you might want to include a guarded set nocompatible in your .vimrc is that compatible will not be automatically unset if you specify the vimrc with the -u flag:
Using the "-u" argument with another argument than DEFAULTS has the side effect that the 'compatible' option will be on by default.
It's for this reason that I have this version* in ...
The default format of the ruler option is directly set in the C core of Vim. If you do not like the default, you can customize it using the 'rulerformat' option and using the statusline format expressions.
By experimenting, it seems the default ruler format (when not customized) is:
│ │ │ │ └ position in the ...
You can concatenate v:fname with '.rb' inside substitute:
I've changed it a bit, it appears that whitespaces after coma is not allowed.
Not an expert, @Martin, but from reading :help set you would need to "unset" the local value of sts in each buffer to have that buffer pick up any new global value. setlocal sts= (or for boolean flags, setlocal flag<). Kinda makes sense, local settings initialized to current global values on open, then keep local values until told otherwise. If there ...
To change the divider for the none current window you can do this with (look up :help fillchars):
To change some content depending on whether it is the current or none current window:
let activebuffer = (a:nr == win_getid()) ? "Active Window" : "None Current Window"
let buf_type = &buftype
The FileType plugin for vim files sets the format options. It contains the following line:
setlocal fo-=t fo+=croql
If you want to overwrite this, create the file .vim/after/ftplugin/vim.vim and add your personal formatoptions to it.
When Vim loads the .vimrc it will first load the global vim.vim FileType plugin and then load .vim/after/ftplugin/vim.vim. ...
Something like this:
if &listchars == g:lc1
let &listchars = g:lc2
let &listchars = g:lc1
nnoremap <F9> :call ChgListchars()<CR>
So it looks like you haven't learnt the Vim terminology and that's the source of your confusion. Forget those "instances", "views" and such. It's all about "buffers" and "windows".
sets noma property for the file in both the editing instance end the view.
To put it properly: "noma is set for the buffer in both windows".
Let's read :h :sview: "same as :...
The difference is whether changing the global option will affect existing buffers other than the current one.
With a regular buffer-local option, the local option is set to match the global option when the buffer is created. When you use a :set command, it sets both the global and the buffer-local option (for the current buffer) to the same value.
But since ...
I have a file called ~/.config/nvim/after/ftplugin_after.vim
The correct path you're looking for is actually:
Note that ftplugin needs to be a directory, and that the *.vim file inside it must be named after the filetype of the files you would like to match.
The ftplugin scripts must always match a specific filetype, ...
I think the setting set smartindent has the behavior you want.
If you use the following .vimrc on a.js, then you can see what's happening when you create a new line and press <cr> in normal mode while the cursor is over the indentation section of the new line.
I'm using the setting set list to make ends of lines visible (as $) and tabs visible (as ^I)...
Assuming you have the following text:
and you search with /Case/+1 from the beginning of the file. The cursor will end up on the text First. You searched for Case and gave the "line offset" +1. (See :help search-offset)
If cpoptions does not contain o and you press n, the cursor ends up on the text Second.
If cpoptions ...
After reading this:
I realised what I needed to do was this:
I have to say, vim script can be a bit inconsistent, using bare strings works fine but without it you need to some some weird stuff to get it to work if you want to use variables.
It seems to me set does both setl and setg. And they all depend if the option is global, local to buffer, or both (global-local).
Relevant vim help documentation:
Handling of local options *local-options*
Some of the options only apply to a window or buffer. Each window or buffer
has its own copy of ...