Skip to content

Instantly share code, notes, and snippets.

@louisrli
Created November 9, 2015 07:13
Show Gist options
  • Save louisrli/b28185f9ce71b5fb571a to your computer and use it in GitHub Desktop.
Save louisrli/b28185f9ce71b5fb571a to your computer and use it in GitHub Desktop.
filetype on
filetype indent on
filetype plugin on
syntax on
set wildmenu
set splitright
" Airline
set laststatus=2
let g:AirlineTheme="dark"
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:goyo_width=110
set wildignore=*.swp,*.bak,*.pyc,*.class,*.jar,*.gif,*.png,*.jpg,*.aux,*.log
" Some of these might be overrided by vim-sensible
set hlsearch
set showcmd
set autoindent smartindent
set autochdir
" Remap command key
let mapleader=","
nore ; :
nnoremap <Leader>p :Gstatus<CR>
nnoremap <Leader>c :Gcommit<CR>i
nnoremap <F2> :bp<bar>sp<bar>bn<bar>bd<CR>
nmap <space> :w<CR>
" latex-box
let g:LatexBox_viewer="open"
let g:tex_flavor='latex' " Default to ft=tex
" Search
set smartcase
set ignorecase
" Relative line numbers
set rnu
" Change tabs to 4 spaces
set expandtab
set smarttab
set shiftwidth=4
set softtabstop=4
" pathogen
execute pathogen#infect()
Helptags
" colors
set background=dark
:colorscheme base16-isotope
" Highlight colors for current line and visual block
set cul
hi CursorLine term=none cterm=none ctermbg=yellow ctermfg=black
hi Visual ctermfg=Black ctermbg=White cterm=none term=none
hi LineNr ctermfg=darkgrey ctermbg=black
hi Search cterm=NONE ctermfg=grey ctermbg=blue
" 2 space tabs
au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.html setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.md setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.less setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.lessimport setl shiftwidth=2 expandtab
au BufNewFile,BufReadPost *.js setl shiftwidth=2 expandtab
" 100 char lines on tex and md files
au BufNewFile,BufReadPost *.tex setl tw=100
au BufNewFile,BufReadPost *.md setl tw=100
" Markdown mode
let g:vim_markdown_folding_disabled=1
" Pyflake
highlight SpellBad term=reverse ctermbg=1
" Don't smartindent in python
au! FileType python setl nosmartindent
au BufNewFile,BufRead *.html set filetype=handlebars
" Syntax checking via Syntastic
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html'] }
let g:syntastic_python_checkers=['pylint']
" .lessimport for Meteor
au BufRead,BufNewFile *.lessimport set ft=less
" ctags
nmap <F3> :TagbarToggle<CR>
set tags+=tags;$HOME
" autoregen ctags with exuberant c-tags
au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &
" autoindent ocaml
autocmd FileType ocaml source /Users/louis/.opam/system/share/typerex/ocp-indent/ocp-indent.vim
" Automatic C / C++ file headers
" (relies on automatic creation of new stars on 'o' )
function! s:insert_header()
let filename = expand("%:t")
execute "normal! i/* "
execute "normal! o" . filename
execute "normal! o"
execute "normal! oTODO: Description "
execute "normal! o"
execute "normal! o/"
normal! o
normal! o
endfunction
autocmd BufNewFile *.{h,c,hpp,cpp} call <SID>insert_header()
" Automatic C / C++ header guards
function! s:insert_gates()
let gatename = "__" . substitute(toupper(expand("%:t")), "\\.", "_", "g")
execute "normal! i#ifndef " . gatename
execute "normal! o#define " . gatename . " "
normal! o
execute "normal! Go#endif /* " . gatename . " */"
normal! k
endfunction
autocmd BufNewFile *.{h,hpp} call <SID>insert_gates()
" Automatic header file inclusion (foo.c includes foo.h)
function! s:insert_header_incl()
let filename = expand("%:t")
execute "normal! i#include " . "\"" . substitute(filename, "\\.c", "\\.h", "g") . "\""
normal! o
endfunction
autocmd BufNewFile *.{c,hpp} call <SID>insert_header_incl()
:imap ;; <Esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment