Disable status line in vim's Syntastic - vim

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.

Related

Vim: How to permanently allow auto indent only on manual linebreak

Vim has a tendency to automagically mess with the indentations in the line I'm currently working on, as well as placing linebreaks. I want it to do an automatic indentation when I manually make a linebreak (i.e. physically hitting the Enter key), but not in any other case, I don't want it to make any linebreaks itself either, and I want these settings to be permanent.
The textwidth option controls the number of characters after which a line break will be inserted, see :h textwidth.
To turn off the insertion of line breaks while editing, the following lines should be added to .vimrc:
set textwidth=0
set wrapmargin=0
set formatexpr=
Information on the options can be obtained by the usual :h command.
Note that these options are set globally but may be overridden e.g. by a filetype plugin. If the problem persists, see :h ftplugin.
Another question is where :set textwidth=132 originates from. This may be due to an earlier misconfiguration or set from any plugin.

vim does remove indent for all lines starting with # character

I have already read this:
Vim automatically removes indentation on Python comments
I have tried everything that is mentioned there without success:
I have smartindent off
I use filetype indent on
I tried the trick with :inoremap # X^H#
None of the above helps: Whenever i start a indented line with a # the indentation is removed and the cursor is moved to column 0.
Here's the output of :set: https://gist.github.com/mikehaertl/5387743
And here's the vimrc.local that i use on Ubuntu 12.10: https://gist.github.com/mikehaertl/1612035
So i'm clueless what else i could try. I don't want my cursor to be moved to column 0 whenever i type an indented #. Any suggestions?
UPDATE
So i found out this is caused by cindent. Still this is very obscure to me: Why does vim do that and how can i prevent that from happening if i still want to use cindent?
If you are using cindent, it probably contains the 0# part which comes by
default. You just have to remove it, for example by using an auto command to
be triggered when the file type changes to the type(s) you want with this
indentation disabled.
Is it PHP? If so, adding this line to your .vimrc may help:
autocmd FileType php set cinkeys-=0#
The 'formatoptions' option governs that behavior. What is the output of :set fo?
croql is a good value, see :h fo-table.

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

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=

Why does Vim ignore my modeline values?

I'm using a Python file with the following modeline at the end:
# vim: sts=4:ts=4:sw=4
If I start Vim with this file the modeline is ignored. How can I fix this? And BTW, I have nocompatible set in my .vimrc.
Here is what you check...
Step 1
Make sure your settings are right. Do...
:verbose set modeline? modelines?
If you see either of these values returned, it's not going to work.
nomodeline
modelines=0
(By adding verbose before the set command, you will be told what file produced that setting. Thank you, drew010)
What you need to see is this (where that 4 is anything greater than 0)
modeline
Last set from /usr/share/vim/vimrc
modelines=4
Last set from ~/.vim/vimrc
Note from the comments: If you have either nomodeline or modelines=0, you are going to need to add set and the corresponding setting from the previous code block. (Thank you #pilat)
Step 2
Do you have a line with a vim: that is not touching any else within the last <modelines> lines of your document?
Seriously, that's all it takes.
These modelines all work...
# vim: cursorline
// vim: cursorline
; vim: cursorline
vim: cursorline
# anything here vim: cursorline
even without a valid comment vim: cursorline
literally anything as long a space separates> vim: cursorline
# vim: set cursorline: <-that colon is required if you use the word "set" and this comment after the colon does not affect it.
Notice that the only way to have a comment after the modeline is to use the word set. But if you use set, you must put a colon at the end of your settings even if you have no comment. Thank you, Amadan
Step 3
And this is an important one! Are you using the word set? (as described as the "second form" in the options doc) Take out the set or add a colon to the end.
None of these work...
# vim: set cursorline
^^^ issue: use of the word set without a trailing colon (:)
# vim:cursorline
^ issue: no space after the colon
#vim: cursorline
^ issue: no space before the word vim
Step 4
Have you been awake for more than 18 hours? Before you lose your mind, get some sleep. It'll still be broken tomorrow. You'll be more likely to notice the issue when you go through this list again then.
Update notes
This answer used to include this claim:
Are you using the word set? (as described as the "second form" in the options doc) Well, that doesn't work in version 8, and I don't know when it stopped working. Use the "first form".
I was wrong. It was pointed out by #Amadan and I have corrected Step 3.
I had a similar issue with my modeline not working. The answers in this thread helped me find my answer (which was adding set modeline to my ~/.vimrc)
https://superuser.com/questions/323712/modeline-not-work-in-vim
Also one thing that helped me debug this was to type :set in vim. This will tell you the different values that are currently set.
If you are saving and loading views, for example with something like the following, your modeline will not be reevaluated when you reopen a file.
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
I tracked the problem to a local plugin, called local_vimrc.vim. The fact that modeline does not work is a side-effect of the plugin.
The first step is always look in
/usr/share/vim/vim74/debian.vim
and comment out the nomodeline line.
Kubuntu distributions consider it a security
threat.
(EG: libcal allows you to run an arbitrary program)
This is only an issue if someone off system can run vim via a webpage. (don't trust user input.)
It is also possible to do a ddos attack using spell checker. (don't trust user input.)
I have had such problem with my modeline and "noexpandtab":
# vim: noexpandtab ft=python
but if I write:
# vim: ft=python noexpandtab
it works again. (Thank you guys for knowledge about :verbose set ... !)

Resources