Hide information below status line - vim

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

Related

What is the correct way in Vim to autocommand ":highlight" after a buffer is loaded?

Due to various reasons, I run Vim at sixteen-colors, synced w/ my terminal's colors. In a recent Vim update, I've had to rework my "~/.vimrc" completely to get it back into running order on Linux.
Initially I was shocked to find that this simple line did not work (even w/ "syntax on" preceding it):
:highlight Comment ctermfg=White
I'm also using a "LineNr" ctermfg. No matter where I placed/stacked the "Comment" ctermfg, it didn't work, or interfered w/ everything else sourcing correctly (ie, placed in the same line w/ "LineNr"). However, I found that calling "Comment" after a buffer had loaded would make the comments appear as intended.
I am new to autocmd in Vim (and want to know how it works, anyways). Is there an "autocmd" call that I can have in my "~/.vimrc" that will run the aforementioned line of code immediately after a buffer has loaded?
I have tried several iterations (BufWritePre, BufWritePost, etc.) and been unsuccessful. This was my previous attempt:
autocmd BufWinPost * :highlight Comment ctermfg=white
Don't resort to :autocmd without reason; search harder for the root cause!
Your description lacks specifics; I guess your chosen colorscheme (or a plugin, but no sane plugin should interfere with the default highlightings) overrides your custom one for Comment. You can check who defined this via
:verbose highlight Comment
If this points to your colorscheme, you simply need to execute your :highlight command after it. For this, you need to understand :help initialization, and maybe check the output of :scriptnames. If you have a :colorscheme foo command in your ~/.vimrc, it should be as simple as putting the :highlight command after it.
You do need an :autocmd if you switch colorschemes on the fly, as most colorschemes override the basic Comment definition. The correct event and pattern for that would be ColorScheme *
If I do a quick :h autocmd-events, I find the the event BufWinPost does not exist. I think, you want BufWinEnter instead. The autocmd you wrote should work, except for the :. HTH

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.

How can I get rid of this "Auto Commands" message from vim?

If I have this line in my vimrc
au VimLeave %bdelete
Then whenever vim starts it says
--- Auto-Commands ---
Press ENTER or type command to continue
I have that line there to empty the buffers from gvim, because new gvim instances have massive :ls output from previous runs. Notably, gvim doesn't actually produce this prompt.
Obviously I can set this instance up to only occur during gvim startup and not console vim, but I'd like to understand this rather than avoid it. Mostly I'm confused that VimLeave seems to cause things to happen on startup.
TIA
Altreus
The problem is that this is an incomplete :autocmd definition, so Vim attempts to list all VimLeave autocommands defined for the pattern %bdelete. You need to specify the any file pattern to make it work:
au VimLeave * %bdelete
Also, check whether you have % in your 'viminfo' option; that one enables the saving and restoring of the buffer list you're complaining about. The f option of file marks may also result in buffers being restored; you could try :set viminfo+=f0.
New Vim instances don't inherit the buffer list of the previous instance unless you add % to the viminfo option.
Setting that option to a sane value will remove the need for your broken fix. Reading the documentation before adding options to your config will prevent you from similar issues.
See :help 'viminfo'.

`vimdiff` not compatible with autocmd?

I was used to use vimdiff and loading the compared files.
Now, on vimdiff execution, it happens:
"a" [readonly] 5454L, 269796C
"b" [readonly] 241L, 10170C
Press ENTER or type command to continue
The only configuration change is the introduction of these two autocmd instructions:
autocmd BufNewFile * call s:Function()
autocmd BufReadPre * call s:Function()
Can this be a normal behavior? Can it be a mistake of mine? Can be something depending on Vim versioning? Can the desired configuration change be combined with a straightforward vimdiff load (no ENTER key needed to continue)?
The dreaded hit-enter prompt is usually triggered by additional :echo[msg] commands, here inside your s:Function(). Either remove them, or silence the output via :silent:
autocmd BufNewFile * silent call s:Function()
If you want to keep whatever messages are displayed in your function, you can set your 'cmdheight' option higher to allow displaying more messages before the "hit enter" prompt appears. This, and other suggestions here: http://vim.wikia.com/wiki/Avoiding_the_"Hit_ENTER_to_continue"_prompts

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

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=

Resources