A minimal, yet effective, vimrc

Posted on

Customizing the way vim works is a lifelong, yet funny, activity. Today I've spent some time to consolidate my vim configuration.

Here it is: it's rather self commenting. The default colorscheme is Spring-Night and you can find it here.

" * General Settings

" This enables Pathogen, hence all the plugins can be
" installed in a subdir named ~/.vim/bundle/SOMETHING.
execute pathogen#infect()

" Four spaces in a tab
set tabstop=4

" Soft tabs
set softtabstop=4

" Four spaces when shifting >> and <<
set shiftwidth=4

" Use spaces instead of tabs
set expandtab

" Menu for autocompletion (on vim commands as well!)
set wildmenu

" Mode for wildmenu
set wildmode=list:longest,full

" Shows horizontal cursor line
set cursorline

" Enable mouse support within vim window
set mouse=a

" Shows line number
set number

" Highlights the searched terms
set hlsearch

" Displays -- VISUAL -- at the bottom
set showmode

" Ignore case when searching
set ic

" Enable the ruler (row/col display)
set ruler

" Enable filetype detection
filetype on

" Enable filetype-specific indenting
filetype indent on

" Enable filetype-specific plugins
filetype plugin on

" Enable syntax highlighting
syntax enable

" Default colorscheme
colorscheme spring-night

" Overrides for mutt: 72 char width for emails
au BufRead /tmp/mutt-* set tw=72

" GUI settings
if has('gui_running')
    "set columns=120
    "set lines=40
    "colorscheme solarized
    "set background=dark

    " Specific GUI settings according to the OS.
    if has("unix")
        let os = substitute(system("uname -s"), "\n", "", "")

        if os == "Darwin"
            " macOS settings
            set guifont=PT\ Mono:h14
        elseif os == "Linux"
            " Linux settings
        endif
    endif

    " Fast switch to tab.
    "map <D-\> :cscope find f
    map <D-1> :tabn 1<cr>
    map <D-2> :tabn 2<cr>
    map <D-3> :tabn 3<cr>
    map <D-4> :tabn 4<cr>
    map <D-5> :tabn 5<cr>
    map <D-6> :tabn 6<cr>
    map <D-7> :tabn 7<cr>
    map <D-8> :tabn 8<cr>
    map <D-9> :tabn 9<cr>
    map <D-S-left> :tabprev<cr>
    map <D-S-right> :tabnext<cr>
endif

"highlight Pmenu ctermbg=238 gui=bold