Skip to content

Instantly share code, notes, and snippets.

@sultanqasim
Last active November 5, 2017 19:13
Show Gist options
  • Save sultanqasim/64ef403337e619e72bc22e4ee71adef2 to your computer and use it in GitHub Desktop.
Save sultanqasim/64ef403337e619e72bc22e4ee71adef2 to your computer and use it in GitHub Desktop.
decent .vimrc
filetype on
filetype plugin on
filetype indent on
" Syntax highlight without being too slow
syntax on
set synmaxcol=255
" Use 4 space tabs by default
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
" Mouse support
set mouse=a
" Highlight search results
set hlsearch
color elflord
" Show line number and file name
set laststatus=2
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=%-3.3n\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%m%r%w " flags
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
set statusline+=char\ %b,0x%-8B\ " current char
set statusline+=line\ %-14.(%l,%c%V%)\ %<%P " position
" Allow copy pasting more than 50 lines
" Store marks in last 50 files, registers up to 300 lines, 20 kb
set viminfo='50,<300,s20
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
" C/C++/Java: Auto indent, auto-complete multiline comments
autocmd FileType c,cpp,java setlocal cindent
" In Makefiles, don't expand tabs to spaces, since we need the actual tabs
autocmd FileType make setlocal noexpandtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment