Skip to content

Tools: Vim

Alexandre Gautier edited this page Oct 12, 2016 · 2 revisions

If you are a vim user and you want to customise tabs and indentation, just read the following guide.

In order to customise your vim configuration, you'll need to modify the file .vimrc in your home directory. If this file does not already exist, you just need to create it.

Don't put anything in your .vimrc you don't understand!

Tabs

To customise tabs length, you can add the following line to your ~/.vimrc:

set tabstop=8 shiftwidth=8

Here, the size of a tab character in Vim is set to 8, so Vim will display 8 spaces on your screen to represent a single tab. You can modify this value, to put a smaller one if you want, but just keep in mind that it's a good habit to keep an indentation of 8 columns: it makes your code more readable.


Indentation

To indent automatically a line depending on the previous one when you hit Enter, just add the following line to your .vimrc:

set autoindent

You can also use intelligent indentation for C code with Vim:

set smartindent
set cindent

Extras

You can enable syntax highlighting in Vim by adding the following rule in your .vimrc:

syntax enable

You can display the current line and column in Vim with the following rule:

set number

0. Betty cli

0.1 - Betty-style usage

0.2 - Betty-doc usage

0.3 - References

1. Coding style

1.1 - Indentation

1.2 - Breaking long lines and strings

1.3 - Placing Braces

1.4 - Placing Spaces

1.5 - Naming

1.6 - Functions

1.7 - Commenting

1.8 - Macros and Enums

1.9 - Header files

2. Documentation

2.1 - Functions

2.2 - Data structures

3. Tools

3.1 - Emacs

3.2 - Vim

3.3 - Atom

Clone this wiki locally