Skip to content.

my Vim

This is my .vimrc, I find it benefitial to use this where I do development to normalise my editor across different operating systems, and to enable some useful untapped features to make Vim feel a bit less prehistoric.

First off, there are some code sections below which will use Vim plugins if it can detect them. I chose to use the Pathogen plugin system as it was the most Plug ‘n’ Play when I first configured Vim.

I know Vim 8 has a native plugin system but that doesn’t help if you’re stuck with an older version of Vim.

The plugins configured below include Fugitive, which lists the current git repository’s state in the status bar & Syntastic which flags up syntax errors when saving.

" Joe's .vimrc
" Maintainer:   Joe Heaton
" Version:      3.0

set encoding=utf-8

" Behaviour
filetype plugin on  " Load plugins with support for specific filetypes
syntax on           " Syntax highlighting
set tabstop=4 expandtab shiftwidth=4 softtabstop=4
set formatoptions-=cro  " Disable automatic line commenting
set linebreak       " Linebreak long lines
set smartcase       " Enable case-sensitivity if string has capitalisation
set ignorecase      " Ignore case when searching with lowercase
set incsearch       " Move cursor to matching strings as you type into search
"set hlsearch        " Highlight search results
set history=1000    " Remember more commands and search history
set tabpagemax=30   " Maximum number of tabs
set scrolloff=3     " Minimum visible lines around cursor
set number          " Show line numbers (set number)
"set number rnu      " Hybrid line numbers on (set number randomnumber)
set ruler           " Show column/row number in status bar
set autoread        " Reads file automatically if modified outside of buffer
set wildmenu        " Visual autocomplete
set wildignore=*.swp,*.pyc  " Ignore files
set shell=/usr/bin/env\ bash    " Shell for Vim terminal

" Delete comment character when joining commented lines
if v:version > 703 || v:version == 703 && has("patch541")
  set formatoptions+=j

" Appearance
set t_Co=256        " Set terminal 256-bit color
colorscheme elflord    " Set theme (Built-in)
"set mouse=          " Disable mouse

" Pathogen pkg manager
if has('pathogen')
  execute pathogen#infect()

"" Statusline
set laststatus=2      " Always show statusline

set statusline=%f     " Path to the file
set statusline+=\     " Separator
if has('fugitive')
  set statusline+=%{fugitive#statusline()}      " Git current branch
set statusline+=%*    " Normal formatting
set statusline+=\     " Separator
if has('syntastic')
  set statusline+=%#warningmsg#                 " Syntastic warning
  set statusline+=%{SyntasticStatuslineFlag()}  " Syntastic warning
set statusline+=%*    " Normal formatting

set statusline+=%=    " Switch to the right side

set statusline+=%#error#  " Formatting
set statusline+=%h    " Help file flag
set statusline+=%m    " Modified flag
set statusline+=%r    " Read only flag

set statusline+=%*    " Normal formatting
set statusline+=%c,   " Cursor column
set statusline+=%l/%L " Cursor line/Total lines
set statusline+=\ %P  " Percent through file

au BufRead,BufNewFile *.j2      set ft=jinja
au BufRead,BufNewFile *.conf    set ft=conf
" Spelling check language
"au BufRead,BufNewFile *.{txt,md,rst,tex} set spell spelllang=en_gb

" Plugins
"" Syntastic
if has('syntastic')
  let g:syntastic_quiet_messages = { "type": "style" }  " Disable style checkers
  let g:syntastic_check_on_open = 1
  let g:syntastic_auto_jump = 2   " Jump cursor to first error
  let g:syntastic_python_pylint_args = '-E'   " Only check for errors
  let g:syntastic_aggregate_errors = 1    " Run all checkers before showing results

" Local additions
if !empty(glob("~/.vimrc.local"))
  source ~/.vimrc.local
Joe Heaton
Cloud High Performance Computing Engineer

Joe Heaton’s technology-focused murmurings.
comments powered by Disqus


Reveal the cookie consent prompt

Use Dyslexia-friendly font OpenDyslexia

Toggle advertisements