Page Body

Customizing vim

Once you have mastered the basics of vim, you may want to start exploring its many options. Using them to tweak the editor to your liking is rewarding and satisfying.

Note: If you are not familiar with the GNU/Linux command line interface, review the Conventions page before proceeding.

In order to make your vim settings persistent, create a .vimrc file in your user's home directory and enter your customizations there.

vim "${HOME}/.vimrc"

As you are adding options to your .vimrc file, you can enter comments using the " symbol. Often, it is helpful to use comments to record what a given setting does, in case you need to reference it in the future.

Here is an example .vimrc file with some useful options to help you get started.

" Copy indent from current line when starting a new line
set autoindent

" Allow backspacing over indention, line breaks, and insertion start
set backspace=indent,eol,start

" Display a confirmation dialog when performing actions that would normally
" fail because of unsaved actions, like closing an unsaved file
set confirm

" Highlight the text line of the cursor
set cursorline

" Display as much as possible of the last line in a window
set display+=lastline

" Enable search highlighting
set hlsearch

" Enable incremental search
set incsearch

" Avoid wrapping a line in the middle of a word
set linebreak

" Increase max memory to use for pattern matching
set maxmempattern=100000

" Disable modelines
set nomodeline

" Show the line and column number of the cursor position, separated by a comma
set ruler

" If in Insert, Replace, or Visual mode, put a message on the last line
set showmode

" Enable syntax highlighting
syntax on

" Set the window's title
set title

" Speed up scrolling
set ttyfast

" Enable wild menu
set wildmenu

" Enable line wrapping
set wrap

Enjoyed this post?

Subscribe to the feed for the latest updates.