Vim has many options you can set to change how it behaves.
There are two main kinds of options: boolean options (either "on" or "off") and options that take a value.
Run the following command:
Line numbers should appear on the left side of the window if they weren't there already. Now run this:
The line numbers should disappear.
number is a boolean option: it can be off
or on. You turn it "on" by running
:set number and "off" with
All boolean options work this way.
:set <name> turns the option on and
no<name> turns it off.
You can also "toggle" boolean options to set them to the opposite of whatever they are now. Run this:
The line numbers should reappear. Now run it again:
They should disappear once more. Adding a
! (exclamation point or "bang") to
a boolean option toggles it.
You can ask Vim what an option is currently set to by using a
?. Run these
commands and watch what happens after each:
:set number :set number? :set nonumber :set number?
Notice how the first
:set number? command displayed
number while the second
Some options take a value instead of just being off or on. Run the following commands and watch what happens after each:
:set number :set numberwidth=10 :set numberwidth=4 :set numberwidth?
numberwidth option changes how wide the column containing line numbers
will be. You can change non-boolean options with
:set <name>=<value>, and
check them the usual way (
Try checking what a few other common options are set to:
:set wrap? :set shiftround? :set matchtime?
Finally, you can specify more than one option in the same
:set command to save
on some typing. Try running this:
:set numberwidth=2 :set nonumber :set number numberwidth=6
Notice how both options were set and took effect in the last command.
:help 'number' (notice the quotes).
Add a few lines to your
~/.vimrc file to set these options however you like.