Random Bits

Technical Log from Didik Setiawan

My Vim Configuration

This is my Vim configuration a.k.a .vimrc. You can download the file from here. Feel free to use and customize.

Below are some description of its contents:

Use vim settings instead of vi

set nocompatible

No backup or swap

set nobackup nowritebackup noswapfile autoread

Enable per-directory .vimrc files

set exrc

Don’t unload buffer when switching away

set hidden

Allow per-file settings via modeline

set modeline

Disable unsafe commands in local .vimrc files

set secure

Saving and encoding

set encoding=utf-8 fileencoding=utf-8 termencoding=utf-8

Command completion

set wildmenu

Allow backspacing over everything in insert mode

set backspace=indent,eol,start

Display status line which contains current mode, file name, file status, ruler, etc.

set laststatus=2

Always set autoindenting on

set autoindent

Display incomplete commands

set showcmd

Keep upto 50 lines of command line history

set history=50

Show a vertical line at the 79th character

set textwidth=80

Highlight column after ‘textwidth’

set colorcolumn=+1

Switch syntax highlighting on

syntax on

Switch highlighting on the last used search pattern

set hlsearch incsearch ignorecase smartcase

Don’t hide the mouse cursor while typing

set nomousehide

Right-click pops up contect menu

set mousemodel=popup

Show cursor position in status bar

set ruler

Show line numbers on left

set number

Disable code folding

set nofoldenable

Scroll the window so we can always see 10 lines around the cursor

set scrolloff=10

Kernel coding style

set tabstop=8                                           
set softtabstop=8                                       
set shiftwidth=8                                        
set noexpandtab

Enable file type detection

filetype plugin indent on

Shortcut to search visually selected text

vnoremap // y/<C-R>"<CR>

Check if running on gvim

if has("gui_running")

Set terminal color to 256

set t_Co=256

Check if using Windows

if has("win32") || has("win16")

Set Ubuntu Mono font with size 11

set guifont=Ubuntu\ Mono:h11

Use solarized colorscheme

colorscheme solarized

Set the background to dark color

set background=dark

Highlight the current line

set cursorline

Use letter as the print output format

set printoptions=paper:letter

I use Ubuntu font which can be download from font.ubuntu.com. To enable solarized colorscheme, download file solarized.vim from https://github.com/altercation/vim-colors-solarized/. If you want to look my personal vim configuration, you can find it here.

I use this configuration in my Linux workstation and server. I use exclusively for editing linux kernel and other open source projects. For daily programming use, you can change the value of tabstop, softtabstop and shiftwidth.
Happy Vimming!

Comments