Hide vim cmdline - vim

I know this is a little OCD, but now that I've tricked out my vim and tmux configs, I'm curious if it's possible to collapse the empty vim cmdline when not in use. It just sits there taking up a precious line of vertical real-estate!

From :help cmdheight:
'cmdheight' 'ch' number (default 1)
global
{not in Vi}
Number of screen lines to use for the command-line. Helps avoiding
hit-enter prompts.
The value of this option is stored with the tab page, so that each tab
page can have a different value.
set cmdheight argument must be positive, so no, it's not possible to hide the cmdline.

In Vim 9.0.0114 and Neovim 0.8 (prerelease), set cmdheight=0 hides the command line.

Related

Vim cursor going outside of character bounds in normal mode

Some setting changed on my vim. In normal mode, I can now click anywhere and my cursor will go there. (This is in normal mode.)
The behavior used to be that if I clicked past the end of the line, the cursor would go to the last character of the line.
I hope I've explained this sufficiently, but is there a way to get the old behavior back?
Thanks!
You probably set the option virtualedit somewhere. To turn it off for the instance you can use :set virtualedit=. Or to permanently disable it remove it from your vimrc.
The feature is call virtual edit. You can disable this with:
:set virtualedit=
See :h 've' for more information.

VIM: Change cursor to underscore in normal mode

One nice feature of Sublime Text's Vintage Mode is that entering normal mode makes an underscore under the character you are one, rather than the standard cursor that highlights the current character with a certain background color.
Is there a way in GUI VIM to change the normal mode cursor to an underscore under the current character you're on like Sublime Text?
Thanks!
Yes, there is. Take a look in :h guicursor. Here's my suggestion, trying to keep it as close as the default configuration for the syntax group.
:set guicursor+=n:hor20-Cursor/lCursor
Option 'guicursor' controls how cursor is displayed.
I've never seen Sublime Text, but line below changes the cursor to underscore on normal mode:
set guicursor=n-ci:hor30-iCursor-blinkwait300-blinkon200-blinkoff150
See :h guicursor for details on how you can change the cursor.

How do I make Vim get the number of rows of the terminal from which it starts?

My work setup has several terminals open, at different heights (e.g. number of lines). How do I make Vim obtain that number of lines so that it can set itself accordingly with set lines?
I'm on bash with iTerm2.
Update: If my .vimrc doesn't have a set lines statement, Vim should adjust itself by default.
Vim's default behaviour is to take up all of the available height. Or 24 lines if it can't get the information from the Terminal emulator according to :h lines.
set lines=52 works in MacVim/GVim but it's not really supposed to do anything useful in CLI Vim besides, eventually, changing the terminal's window height.
From my limited use of iTerm2 Vim behaves as it should. So do you want Vim to take less vertical space than what is available? Or more?
Though the reason didn't require it, in case someone comes across this while trying to figure out how to get the number of rows in a terminal at startup... the answer is to use "&lines".
Eg. to enforce laststatus to display unless you are working in a small window.
if &lines > 10 | set laststatus=2 | endif

Is it possible to not display a ~ for blank lines in Vim/Neovim?

Is it possible to not display a ~ for blank lines in Vim?
This confuses Mac Vim's scrollbar, and I quite don't like these tildes.
:hi NonText guifg=bg
That command should set the color of non text characters to be the same as the background color.
Vim 8.x:
You can now change the color just for the end of the buffer ~:
highlight EndOfBuffer ctermfg=black ctermbg=black
See changelog for Vim 8.x.
As jamessan said, you can’t disable them. The scrolling behavior isn’t specific to MacVim, either — it works the same way in the terminal and in gvim:
Instead of seeing this as a problem, what you should do is learn to see this as part of Vim’s flexibility. For example, you can use the zt command to scroll the current line to the top of the screen, regardless of where in the file it is. This can make it easier to write macros that do some work and then scroll back to where you were. The commands <C-E> and <C-Y> are made simpler because of this, as is the 'scrolloffset' option.
If you must, retrain your brain to think of Vim’s scrollbar as mapping to which line is on top, instead of which screenful is visible.
For NeoVim, you can set the fillchars value for eob to a space character and that will effectively hide it. (This might not work for plain Vim).
In Lua (Nvim 0.5+):
vim.wo.fillchars='eob: '
In VimScript:
set fillchars=eob:\
Note: Calling the above will override your fillchars value for other items as well (if set), so use this as a reference to set multiple values together:
set fillchars=eob:\ ,fold:\ ,vert:\│
Or use set fillchars+=... to append it your existing values.
You can't disable them, but you can change your colorscheme such that the NonText highlight group is colored the same as the Normal highlight group. However, this affects more than just the end of document tildes.
I doubt that it's actually "confusing" MacVim's scrollbar and if it is, then that's a bug in the patching that MacVim does.
The tilde ~ characters are meant to remind the user that those lines are not part of buffer content.
The above highlight trick will hide the ~ character, but it is still there. For some terminals, this may not even work. If you happen to be a Neovim user, you can use fillchars option to change the end of buffer symbol like this:
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
This will use space instead of ~ for end of buffer, effectively hiding the annoying ~.
You may also be interested in discussions here.

Configure Macvim's text selection to not include character under cursor

Using macvim, when I copy a text selection, it always includes the character under the cursor.
For example, if the cursor is at the far left and I press shift-down arrow, it selects the entire line plus the first character of the next line (since the cursor is sitting over the next line's first character).
Is there a way to configure macvim to not include the cursor character in text selections?
Take a look at the selection option. By default it's set to inclusive, but you can change it to exclusive to make text selections act the way you want:
:set selection=exclusive
You can also set it to exclusive with the behave command:
:behave mswin
This also sets several other options, however, which may or may not be what you want. See the Vim help for the specifics.
:help :behave
:help 'selection'
I am guessing that shift-down arrow activates visual character mode, and moves the cursor down a line. If you are trying to select entire lines, you would be better off using visual line mode, which is activated from normal mode by pressing V (shift-v). This will select the current line in its entirety. You can then extend your selection to include the lines above and below using the k (or up arrow) and j (or down arrow) keys.
When using Vim, I think it is better to go with the grain rather than to fight against it. Don't expect it to work the same way as other text editors. Accept that the Vim way is different.

Resources