You can fold/collapse lines in vim. Let’s say you do it manually, do
Then highlight the lines you want to fold. Then press
zf. You can open and close folds with
But the line vim gives you is an ugly light grey colour. You can change this to black via
:hi Folded ctermbg=black.
cterm since I’m using the text console. Otherwise I’d use guiterm
Let’s take the command Control W <. This expands the left hand window in a split window.
The only problem with this is that you must first press control w, then shift, and then ,. At least on my keyboard.
Let’s remap this Control w < to Control w ,. This will save us pressing the shift key.
:nmap [press control v][press control w], [press control v][press control w]<
You can also put this in your .vimrc file for activation on startup.
Pressing control v allows you to then enter a control key in the command.
n is nmap means this only applies in normal mode.
If you are using vim a lot, and touch type, you may find reaching up to press escape all the time ruins your typing.
You can rebind escape to caps lock, and vice versa, throughout all your X apps using
Use this in
clear Lock keycode 9 = Caps_Lock keycode 0x42 = Escape
And then use the command, probably in your
xmodmap ~/.Xmodmap to do the rebind.
set -o vi and you can press escape (or whatever you’d bound that to) to use the vim commands on the current commanded typed in on the command line.
You can also press
v and it will open up vim and you can edit the command in the full vim editor.
You made need to put
EDITOR=vim in your
If you start typing in vim, then press
ctl n, vim will give you a list of autocomplete options.
In this list you can press
ctl n and
ctl p to navigate the list.
However, by default, vim won’t show you any autocomplete options with a dash in them.
For instance, if you have the text
this-is-a-variable. And you start typing
t, and then press
ctl n, it will only show you
To make the autocomplete list include items that have a dash in them, add to the