5

Yes, it's parentheses (aka "item group"). Sort of let &statusline = '%f%( %r%)%( %y%)' Some time ago I also wrote a plugin (actually a function) to assist in building status line expression from simple "blocks".


5

Simple status line: filename and filetype As you can see with :set statusline?, the default 'statusline' option is empty in vim. You'll need to overwrite it. Here's the most simple example with filename and filetype: set statusline=%f%=%{&filetype} %f : filename %= : separation between left and right %{filetype} : obviously, the file type See :h '...


5

Well, it looks the answer is as simple as :set statusline=%v That uses the virtual column number instead of the column number. Thanks to D. Ben Knoble for pointing me in the right direction.


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


4

The easiest way would be to call git inside %{} like so: let &statusline = '%{substitute(system("git status -s"), "\n", " ", "g")}' Anything inside %{} get evaluated as an expression, and here we call git status -s with system() and replace newlines with a space, resulting in a statusline like: ## repl M db.go ?? ...


4

An alternative is to wrap more things in square-brackets, obviating the need for spaces (a modified version of what I start with): let &statusline = '%([%f]%)%(%m%r%w%h%)%(%y%)' Not all of the grouping is necessary, but I actually break my statusline out over multiple lines in my vimrc, so I just group everything. And there's this from :help statusline: ...


4

Another option is to use a conditional: set statusline+=%{&readonly?'\ [RO]':''} This allows you to also change what is shown. For example, I have: set statusline+=%{&readonly?'\ !!':''}


4

Plugins are loaded after the .vimrc has been parsed. See :h startup. Either check with globpath() whether the file you're interested in is installed where it should be -- but I guess it won't tell anything if it refused to load before setting the variable. (This is the same idea as the one described in this Q/A on SO: In my .vimrc, how can I check for the ...


3

That is not possible. The statusline can only cover one single line. As a hack, you might be able to use the tabline in addition to the statusline to show some information. Airline for example allows to display the statusline in the tabline as an experimental extension: * Display the statusline in the tabline (first top line): let g:...


3

To add a pipe, escape it with double \\|: func! VimMode() abort let md = mode() if md == 'n' return 'NORMAL' elseif md == 'v' return 'VISUAL' else " check mode() help to define other mode names here return 'OTHER' endif endfunc set statusline=%{VimMode()}\ \\| set statusline+=\ %f set statusline+=%< ...


2

Vim features are not completely orthogonal, so not all of them are available as individual flags to enable/disable. If you want a minimal build of Vim, you can use --with-features=tiny. I believe this will disable the statusline feature as well, together with many other features disabled to produce a minimal build. This setting is already available in the ...


2

Vim supports inter-process communication via its +clientserver feature. If it is listed in vim --help, you can solve it by starting Vim as a server (if using Gvim, it by default starts as a server so you could skip this step): vim --servername CAPS Then have the following shell script running in the background. It requests all Vim servers to modify the ...


2

The stuff is known to work in Neovim, but not in Vim, because Vim is too lazy when updating screen, as @Mass correctly noted in the comments. Personally, I just don't pay attention to this, and keep using my status line plugin without any worries. But if you are so eager to fix it, you need to force status line redrawing, e.g.: augroup test | au! autocmd ...


2

I suspect https://github.com/vim/vim/pull/6970 and related https://github.com/vim/vim/issues/4405 Basically, before the patch it was impossible to put vim into full "default colors mode" as there were no way to do it -- :hi link survived :hi clear. Also cleared highlight groups were impossible to set with :hi def groupname .... I guess that ...


2

You can hit g Ctrl+g and you get the full information about the position: Col 13 of 35; Line 18 of 2272; Word 70 of 7767; Char 410 of 50021; Byte 410 of 50118


2

To display the byte position you can use the following command :echo line2byte(line("."))+col(".")-1 See Question: Get offset of current buffer in vim


2

" starts a comment in VimScript. Please, take your time reading :h :comment and :h :bar and remembering the rules. You must either escape it with backslash or use another command that accepts quote as part of argument. UPD. Also, you're not allowed to have nested braces here (thanks to @filbranden for spotting this). And so we have "WRONG set ...


1

This is just normal. %f stands for current buffer's name (:h bufname()) and it gets inserted as is, i.e. !cat vimrc, plus status, i.e. [finished]. To change terminal's buffer name call term_start('cat vimrc', {'term_name': 'foobar'}) To setup status line for terminal windows only augroup test | au! autocmd TerminalWinOpen * setlocal statusline=foobar ...


1

There are some issues with the approach you described. First, you are calling autocmd! outside of an augroup. This is really bad, since it's actually erasing all auto-commands! Second, the logic in SetFiletype() looks odd, since it's first checking whether the file type is "vim" and then creating an auto-command to set the highlight group when ...


1

Try installing the lightline-bufferline plugin. The README constains instructions on how to show buffers in lighline.


1

This can be done much more simply with the expand() command: function! SetStatusLinePath() return expand("%:h") . "/" endfunction function! SetStatusLineFile() return expand("%:t") endfunction set statusline+=%#pwd#%{SetStatusLinePath()} set statusline+=%#file#%{SetStatusLineFile()} see :h expand()


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