Is there way to disable the status line for certain windows? - vim

A buffer plugin I use creates a separate window with a list of buffers. This unnecessarily has its own status line which takes up space. Is there a way to disable the statusline for certain buffers/windows?

Unfortunately, it is not possible to switch status line visibility
selectively for certain windows. The only related feature is
controlled by the laststatus option that defines when to display
the status line of the last window.
You might be interested in the buftabs plugin that shows a list
of buffers in the status line saving vertical screen space for editing.

Try to emulate absence of statusline instead:
let &l:statusline='%{getline(line("w$")+1)}'
. It is also almost possible to put correct highlighting there, but implementation should be slow.

Actually you can write a small function and put it in autocommands, which will disable and enable laststatus option depending of current buffer name.
Something like that:
au BufEnter,BufWinEnter,WinEnter,CmdwinEnter *
\ call s:disable_statusline('buffer name')
fun! s:disable_statusline(bn)
if a:bn == bufname('%')
set laststatus=1
else
set laststatus=2
endif
endfunction

You could set it locally:
setlocal statusline=

Related

How to disable automatic indentation by Slimv for non-Lisp files?

Non-Slimv Behavior
At first, let me show the normal Vim behavior when Slimv is not enabled.
Create a new file: vim foo.c.
Enter insert mode: i
Enter this code: void f()
Press enter
The cursor is now at position 2,1 (2nd row, 1st column).
Slimv Behavior
After installing Slimv, if I perform the steps above, at the end, I find the cursor at position 2,5 (2nd row, 5th column) with four spaces inserted as indentation before the 5th column automatically.
How can I disable this Slimv behavior for non-Lisp files (such as .c files)?
The issue is caused by this line in paredit.vim:
filetype indent on
I added the option g:paredit_disable_ftindent to paredit.vim to disable the loading of indent files, please add this line to your .vimrc when using paredit.vim (or slimv that also contains paredit.vim):
let g:paredit_disable_ftindent=1
First, add to your vimrc file the following two lines:
filetype indent off
filetype plugin indent off
Then you have to hope that it’ll work! But there is a large probability that it won’t…
If the solution doesn’t work, you may have to make quite complicated actions to solve the trouble.
The problem is that many of your vim options are constantly changed by a lot of triggers and auto commands. The only way I found is to mark the important options (the options I don’t want to be changed) with a special symbol, and then to restore them forcibly after any possible impact. So, I did the following in my vimrc:
augroup MyVimrc
autocmd!
augroup END
"The options I want to keep unchanged, I mark with the “❗” symbol.
"The usual exclamation sign “!” will work as well.
"Of course, you’re free using any other symbol you like,
"but don’t forget the lambda-function in the hack below.
"These are the options that may influence on the indent.
set formatoptions=j "❗
set autoindent "❗
set nosmartindent "❗
set indentexpr= "❗
set copyindent "❗
set preserveindent "❗
"And I marked with the same way a number of other
"important (for me) options… (not shown here)
"At the bottom of the vimrc file, I wrote this dirty hack.
function! s:keep_options()
for line in filter(readfile($MYVIMRC), 'v:val =~ ''\v\".*(!|❗)\s*$''')
exe line
endfor
endfunction
command! KeepOptions call <SID>keep_options()
"Note, the “OptionSet” trigger doesn’t work always, so that I preferred “BufEnter”.
autocmd MyVimrc BufEnter * KeepOptions
And all the troubles with unpredictable changes in my settings, at last, have gone.

Disable status line in vim's Syntastic

I use syntastic plugin for vim on a computer with small screen, so want to cut out the unnecessary space. But, syntastic, when there's an error, displays e.g.:
[Syntax: line: 5 (1)]
a.cpp|5 col 59 warning|some error
[Location List] :SyntasticCheck gcc (cpp)
Vim status bar
Is is possible to remove the status line ([Syntax: line...) and the last line ([Location List...), which I don't necessarily need?
I tried disabling the loclist altogether (then I see the warnings/errors in the vim status bar), but I cannot scroll status bar, when it's too long -- but maybe it is possible?
Before turning on loclist:
After:
Here I have already removed the statusline formatting string from my ~\.vimrc. I would like the loclist to occupy one extra line, now it takes 3.
What you need is to hide the statusbar.
Take a look at this post, which implements a function to toggle that functionality.
Or, to disable it altogether:
set noshowmode
set noruler
set laststatus=
set noshowcmd
I think the it's not possible to entirely solve the problem that I asked for, as the loclist is considered another vim window and as such, the first extra line is a mandatory status line of the main window. One can disable the second extra line though by passing:
set laststatus=0
To disable the status bar (the top bars, not the bottom line with format '%d' ...)
Supposedly set laststatus=0 should work. However I noticed this was not working in my vimrc but would work if set manually for each vim session.
To resolve this issue, I added an autocmd within my .vimrc to override any existing laststatus setting:
# ~/.vimrc
" Hide Status Line
set laststatus=0 " For some reason this doesnt work
autocmd BufRead,BufNewFile * set laststatus=0 " This will work instead
As Weston Ganger said, laststatus=0 may not work in the vimrc file. In my case, the reason was in the vim-airline plugin. As stated in https://bbs.archlinux.org/viewtopic.php?id=241303, in airline.vim has a line set laststatus=2, which just needs to be corrected to set laststatus=0.

Hide information below status line

I have laststatus=2 and the statusline with a file name and stuff. I'd like to get rid of the information shown below the status in the command area. Setting noruler has no effect. The text looks e.g. after switching buffers like this:
"localization.cpp" [Modified] line 60 of 118 --50%-- col 1 ((1) of 9)
Any idea?
When switching buffers, Vim prints a message similar to the one in your question (though I don't recognize the exact format). The verbosity of this can be influenced via the 'shortmess' option, but to completely turn this off, you'd have to override the buffer switch commands / mappings to use :silent.
It might also be a custom :autocmd that prints those messages. Can you reproduce this with a plain vim -N -u NONE, and does it disappear when you :set eventignore=all?!
Edit: Since this seems to be the default message from Vim, you can only workaround this by explicitly clearing it via an :autocmd:
:autocmd BufWinEnter * call feedkeys("\<C-\>\<C-n>:\<CR>", 'n')

Why :help ignore :set number in .vimrc?

I :set number in ~/.vimrc to show line numbers. When I type :help to view documentation, the line numbers don't show in the new window.
If I type :setl number?, it prints nonumber. If type :setg number?, it prints number.
I want to know why ~/.vimrc doesn't work. Which script resets the local number option?
I've checked the $VIMRUNTIME/ftplugin/help.vim, but it doesn't reset the number.
Currently, I'm using:
if has('autocmd')
auto FileType help set number
endif
Thanks.
I'm not sure what is the problem you're having. Numbers don't show up in help - yes, if I recall correctly that is a design decision and a feature - a good one, in my opinion, since why would one want line numbers in help files? (Okey, you could say "to quote a particular line from help file" but tags seems sufficient for that).
As far as the other thing go, when I set
setl nonumber
setg number
and open a new buffer in a split, numbers show.
If I start a new vim session, setlocal and setglobal number being nonumber and set number they're both changed.
Is this the behaviour you're having too?
After opening vim, simply type:
:auto FileType
Do you see set number listed under help? If not, your .vimrc is not being read.

Vim status line not changing / clearing

No matter what I change status line to with set statusline my status line will not change. It looks like
".vimrc" 39L, 578C 1,1 All
with the cursor position and the percentage through the file as well as the filesize and filename. It is the only line at the bottom.
How to I hide or change the status line?
How do I clear the status line?
Why is the status line not working?
What you are looking at is a ruler - a "statusline" in a way, but not a statusline. What can be changed in it you can see in help rulerformat.
If you wish to hide the ruler set set noruler, and afterwards enable the statusline with set laststatus=2 if you wish for every window to have their own statusline (the most common). Depending on what you want in your statusline, you might wish to read help statusline, and afterwards put it in set statusline=... (when adding options add them with set statusline+=... one by one - that way you can more easily turn some on or off).
As the first line, when setting statusline, set set statusline= that way statusline is cleared before it is loaded again. You'll figure this out when you source it the first few times.
What you are looking at is the ruler. You can get rid of it with
:set noruler
However, if you want to customise it, you can use
:set rulerformat=
and follow the same format as the status line.
To hide the status bar use:
:set laststatus=0

Resources