Hot answers tagged

29

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 ...


18

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.


12

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> Caveats: There are a few things you need to do to your vimrc to make sure ...


11

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 ...


8

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 ...


8

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 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 ...


8

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.


7

: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, ...


6

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 ...


4

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: :set rulerformat=%l,%c%V%=%P │ │ │ │ └ position in the ...


3

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 allowed.


2

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 ...


2

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>


2

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 window: function SomeText(nr) let activebuffer = (a:nr == win_getid()) ? "Active Window" : "None Current Window" let buf_type = &buftype return ...


2

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. ...


2

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 else let &listchars = g:lc1 endif endfunction nnoremap <F9> :call ChgListchars()<CR>


2

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 :...


1

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 ...


1

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 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, ...


1

One alternative option would be to use view or vim -R <filename>, which opens the file in read-only mode. Then edit it in another instance of vim.


1

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)...


1

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 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 ...


1

After reading this: let &backupdir=s:vimetc.'backups/' I realised what I needed to do was this: let &runtimepath=&runtimepath.','.g:repos_path."Shougo/dein.vim" 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.


1

Actually, the comma is interpreted by set+= command. So for this to work, one should escape it: set backupskip+=*/web/static/{js/*.ts\\,templates/*.html}


1

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* *:set* ... 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 ...


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