Skip to main content
Share Your Experience: Take the 2024 Developer Survey
40 votes
Accepted

Does "set" command affect only the active buffer?

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 ...
romainl's user avatar
  • 41.1k
37 votes
Accepted

How to apply a setting in all open tabs and windows?

Yes, there is! You can accomplish this with :tabdo and :windo. For your case specifically: :tabdo windo set number See :help :tabdo and :help :windo for more information.
Tumbler41's user avatar
  • 7,756
12 votes
Accepted

How can I edit my Vim configuration whilst working in Vim?

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. ...
Tumbler41's user avatar
  • 7,756
11 votes
Accepted

How can I use the return value of a function in a :set command?

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 ...
Ingo Karkat's user avatar
  • 17.9k
11 votes
Accepted

Can I set multiple 'options' with a single `:set` command spread over multiple lines?

I'd personally recommend against doing so, but you can use Vim's "line continuation" feature for this: set number \ showmatch \ hlsearch This will be interpreted by Vim as if the contents ...
Rich's user avatar
  • 32.1k
10 votes
Accepted

Advice to add `set nocompatible` as first line of .vimrc

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 (...
Matt's user avatar
  • 20.8k
9 votes

How to apply a setting in all open tabs and windows?

: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 ...
Tommy A's user avatar
  • 6,790
8 votes

set completeopt=noinsert fails

The noinsert option became available with Vim version 7.4.775. Your Vim on the raspberry pi is (probably) older. You can check with :version.
Karl Yngve Lervåg's user avatar
7 votes

Advice to add `set nocompatible` as first line of .vimrc

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 ...
Rich's user avatar
  • 32.1k
7 votes
Accepted

Default rulerformat

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 ...
Christian Brabandt's user avatar
7 votes

Unable to :set printoptions for :hardcopy command

I would do: set printoptions=left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5 The set command needs: an equal sign (=) and no space ( ) in the argument. Or the variable alternatives: let &...
Vivian De Smedt's user avatar
5 votes
Accepted

toggle listchar settings

Something like this: let lc1='tab:»-,trail:·,nbsp:×,eol:$' let lc2='tab:<->,trail:X,nbsp:_,eol:/' function ChgListchars() if &listchars == g:lc1 let &listchars = g:lc2 ...
Ralf's user avatar
  • 9,257
5 votes
Accepted

What does 'set setting^=value' really mean?

As help states: or prepend the {value} to a string option. Option directory is a string, so if you have set directory=path1,path2 and then do set directory^=path0, result directory would be path0,...
Maxim Kim's user avatar
  • 13.5k
5 votes
Accepted

remove from comma-separated option (listchars)?

The answer is at :help :set-=: :se[t] {option}-={value} *:set-=* Subtract the {value} from a number option, or remove the {value} from a string option, if it is ...
D. Ben Knoble's user avatar
  • 26.4k
5 votes

Unable to :set printoptions for :hardcopy command

The other answers do a great job of explaining how to accomplish your goal. I'll play the unpopular part and explain your error. Let's split your line into two parts and take a look at them ...
Friedrich's user avatar
  • 2,125
3 votes

Use includeexpr to make multiple changes

You can concatenate v:fname with '.rb' inside substitute: :set includeexpr=substitute(v:fname,'::\\(.*\\)','\\1.rb','') EDIT: I've changed it a bit, it appears that whitespaces after coma is not ...
grodzik's user avatar
  • 4,638
2 votes

How to apply a setting in all open tabs and windows?

Another way to keep the current tab:https://vi.stackexchange.com/a/31903 I personally use buffers instead of tabs so I have: " Toggle line numbers for all buffers/windows/tabs function! ...
Michael John's user avatar
2 votes

Does "set" command affect only the active buffer?

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: *:se* *:...
dosentmatter's user avatar
2 votes

Does "set" command affect only the active buffer?

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 ...
Brian Tiffin's user avatar
2 votes

Pressing Enter removes indentation

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 ...
Greg Nisbet's user avatar
  • 1,849
2 votes

Option doesn't happen when opening vimrc?

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 ...
Ralf's user avatar
  • 9,257
2 votes

What is 'cpoptions' += o?

Assuming you have the following text: Test Case First Test Case Second 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 ...
Ralf's user avatar
  • 9,257
2 votes
Accepted

How do I `set <A->>=foo`?

You can use the following syntax to map the "alt + greater than" key combination set <a-char-62>=... 62 being the ASCII code for >. This syntax also works for maps nnoremap <a-char-62&...
Mass's user avatar
  • 14.1k
2 votes

Set different values for non-current and current statuslines

To change the divider for the none current window you can do this with (look up :help fillchars): set fillchars=stlnc:- To change some content depending on whether it is the current or none current ...
run_the_race's user avatar
2 votes
Accepted

How to toggle `modifiable` property

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 ...
Matt's user avatar
  • 20.8k
2 votes
Accepted

How to get autocomplete for :set?

This was recently implemented. Just update to Vim 9.0.1958 and it will just work. Relevant commit: patch 9.0.1958: cannot complete option values Problem: cannot complete option values Solution: Add ...
ychin's user avatar
  • 56
2 votes

Unable to :set printoptions for :hardcopy command

Try this and see what happens: set printoptions=left:2pc,right:2pc,top:2pc,bottom:2pc,header:0,paper:A5 I just tried it and it worked here. Vim 9.1, patches through 408, compiled by me
MDeBusk's user avatar
  • 436
1 vote

Can I copy options (everything shown when I run `:set` with no arguments) between active windows

An option can be buffer-local, window-local, or global. Global options are, well… global, so they are valid globally unless overridden localy. Window-local options only have effect in the current ...
romainl's user avatar
  • 41.1k
1 vote
Accepted

Why won't vim source my ftplugin_after.vim file?

I have a file called ~/.config/nvim/after/ftplugin_after.vim The correct path you're looking for is actually: ~/.config/nvim/ftplugin/filetype.vim Note that ftplugin needs to be a directory, and ...
filbranden's user avatar
  • 29k
1 vote
Accepted

Options such as expandtab reset based on which file I edit

Vim may override your global settings with filetype-specific settings through filetype plugins. (There are also indent plugins that can affect this behavior.) In the specific case of Python shift ...
filbranden's user avatar
  • 29k

Only top scored, non community-wiki answers of a minimum length are eligible