Skip to content

Instantly share code, notes, and snippets.

@smyrman
Last active October 22, 2015 13:47
Show Gist options
  • Save smyrman/3818006 to your computer and use it in GitHub Desktop.
Save smyrman/3818006 to your computer and use it in GitHub Desktop.
vimrc file of Sindre Myren
" Set default max line with for all filetypes to 120.
set noexpandtab sw=8 sts=8 ts=8 tw=120
" Set max line width for Git commit to 79.
if &filetype == 'gitcommit'
set tw=79
endif
" Strip trailing white space on write (preserve cursor position).
autocmd BufWritePre * kz|:%s/\s\+$//e|'z
" Set default max line with for all filetypes to 120.
set expandtab sw=4 sts=4 ts=4 tw=120
" Set max line width for Git commit to 79.
if &filetype == 'gitcommit'
set tw=79
elseif &filetype == 'html' || &filetype == 'htmldjango'
set expandtab sw=4 sts=4 ts=4 tw=119
endif
" vimrc file of Sindre R. Myren
" ## General #################################################################
set nocompatible
set smartcase
set smartindent
set autowrite
set mouse=a
set clipboard=autoselect
set ttyfast
" ## Plugins ################################################################
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
" Plugins.
Plugin 'gmarik/vundle'
Plugin 'embear/vim-localvimrc' " enables project specific .lvimrc files
Plugin 'scrooloose/syntastic'
Plugin 'The-NERD-tree'
Plugin 'terryma/vim-smooth-scroll'
Plugin 'jnwhiteh/vim-golang'
Plugin 'jmcantrell/vim-virtualenv'
" Filetypes.
Plugin 'lunaru/vim-less'
" Color Schemes.
Plugin 'Lokaltog/vim-distinguished'
filetype plugin indent on
call vundle#end() " required
filetype plugin indent on " required
" ## Plugin cfg ##############################################################
" vimrc projects.
let g:localvimrc_ask=0
" Syntastic config.
let g:syntastic_go_checkers=['go', 'govet', 'golint', 'gofmt']
let g:syntastic_py_checkers=['flake8']
" NERDTree config.
let suffixes = ['.pdf', '.log', '.out', '~', '.o', '.3', '.6', '.aux', '.toc', '.bbl', '.blg', '.log', '.pyc']
let NERDTreeIgnore = []
for suffix in suffixes
let NERDTreeIgnore += [ escape(suffix, '.~') . '$' ]
endfor
" Smooth scroll
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 0, 2)<CR>
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 0, 2)<CR>
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 0, 4)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 0, 4)<CR>
noremap <silent> <PAGEUP> :call smooth_scroll#up(&scroll*2, 0, 4)<CR>
noremap <silent> <PAGEDOWN> :call smooth_scroll#down(&scroll*2, 0, 4)<CR>
" ## Apperance ###############################################################
syntax on
set number
set background=dark
set t_Co=256
colorscheme inkpot
" Fancy display of tabs:
set listchars=tab:»\ ,trail:~,extends:>,precedes:<
set list
" Highligt trailing whitespaces, and spaces before a tab.
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$\| \+\ze\t/
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" ## Functions ###############################################################
function! IndentSoft(num)
let &ts=a:num
let &sw=a:num
let &sts=a:num
set expandtab
endf
function! IndentHard(num)
let &ts=a:num
let &sw=a:num
let &sts=a:num
set noexpandtab
endf
function! StripTrailingWS()
augroup rmws
autocmd!
autocmd BufWritePre * :%s/\s\+$//e
augroup END
endf
function! AllowTrailingWS()
augroup rmws
autocmd!
augroup END
endf
function! PythonVirtualEnv(path)
let activate_this = a:path . '/bin/activate_this.py'
if getftype(a:path) == "dir" && filereadable(activate_this)
python << EOF
import vim
activate_this = vim.eval('l:activate_this')
execfile(activate_this, dict(__file__=activate_this))
EOF
endif
endfunction
" Commands.
command! -nargs=1 SIndent call IndentSoft(<f-args>)
command! -nargs=1 HIndent call IndentHard(<f-args>)
" Hotkeys ####################################################################
set pastetoggle=<F2>
map <silent><F3> :NERDTreeToggle<cr>
map <silent><F5> :set nospell<cr>
map <silent><F6> :set spell<cr>:set spelllang=en<cr>
map <silent><F7> :set spell<cr>:set spelllang=nb<cr>
map <silent><F8> :set spell<cr>:set spelllang=nn<cr>
" ## Filetypes ###############################################################
call StripTrailingWS() | call IndentHard(8) | set tw=119
au BufNewFile,BufReadPost *.{rst,tex} call IndentHard(4) | set tw=119
au BufNewFile,BufReadPost *.py call IndentHard(4) | set tw=119
au BufNewFile,BufReadPost *.{xhtml,html,xml,php,css,less} call IndentHard(4) | set tw=119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment