Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Vimscript settings options


May 24, 2021 Vim


Table of contents


Vim has a number of options that can be set to change the way it is presented.

There are two main options: the Boolean option (value "on" or "off") and the key value option.

Boolean option

Do the following command:

:set number

If you didn't see a line number on the left side of the screen before, you'll see a line number now. To execute a command:

:set nonumber

The line number should disappear. number is a Boolean option: yes, no. Open :set number command, :set nonumber command close.

All Boolean options are this configuration method. :set <name> Open :set no<name>

Switch boolean options

You can "switch" the value of the Boolean option, i.e. cut from on to off or cut from off to on. To execute a command:

:set number!

The line number is displayed again. Execute the command again:

:set number!

The line number should disappear again. A dd a ! After the (exclamation point) to Boolean option, the value for the option is switched.

View the current value of the option

You can use ? T he symbol gets the current value of an option from Vim. Follow the command and see the return results for each command:

:set number
:set number?
:set nonumber
:set number?

Note the first :set number? The command number and the second return is nonumber

Key value options

Some options are not just off or on states, they require a value. Follow the command to see the returned results:

:set number
:set numberwidth=10
:set numberwidth=4
:set numberwidth?

numberwidth changes the column width of the row number. Y ou can change the option value of the non-Boolean option by using the : :set <name>? :set <name>=<value> The command views the current value of the option.

Take a look at the values of some common options:

:set wrap?
:set shiftround?
:set matchtime?

Set multiple options at once

Finally, you can set the :set options in one :set command. Try these commands:

:set numberwidth=2
:set nonumber
:set number numberwidth=6

Notice how the last command sets two option values at once.

Practice

Read :help 'number' (note that there are single quotes) help documentation.

Read :help relativenumber help documentation.

Read :help numberwidth help documentation.

Read :help wrap help documentation.

Read :help shiftround help documentation.

Read :help matchtime help documentation.

Add a few settings options ~/.vimrc file to your preferences.