Skip to content

Instantly share code, notes, and snippets.

@mackwic
Created January 22, 2014 15:38
Show Gist options
  • Save mackwic/8560903 to your computer and use it in GitHub Desktop.
Save mackwic/8560903 to your computer and use it in GitHub Desktop.
set nocompatible | filetype indent plugin on | syn on
source ~/.vim/bootstrap.vim
let g:addons = [
\ 'github:sjl/vitality.vim', 'sensible', 'github:sjl/badwolf',
\ 'vim-airline', 'ctrlp', 'Syntastic', 'github:myusuf3/numbers.vim',
\ 'github:rking/ag.vim', 'delimitMate', 'endwise', 'WebAPI', 'Gist',
\ 'fugitive', 'github:spiiph/vim-space',
\ 'github:mtth/scratch.vim', 'surround', 'JSON',
\ 'github:stephpy/vim-yaml', 'vim-coffee-script', 'editorconfig-vim',
\ 'jade', 'github:kongo2002/fsharp-vim'
\ ]
call SetupVAM()
" General configuration --------------------------------------------------- {{{
" Prevent security exploits with modelines files
set modelines=0
" When I use some non-bash compatible shells
set shell=/bin/bash
" Force 256 colors mode because fuck old terms
set t_Co=256
" Use system clipboard
set clipboard=unnamed
colorscheme badwolf
" Backups {{{
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
set backup " enable backups
set noswapfile
" }}}
" }}}
" Editor basics ----------------------------------------------------------- {{{
set encoding=utf-8
set scrolloff=3
set showmode
set showcmd
set hidden
set wildmenu
set novisualbell
set cursorline
set ttyfast
set ruler
set list
set backspace=indent,eol,start
set listchars=tab:\▸\ ,eol:¬,nbsp:·
set laststatus=2
set wrap
set textwidth=80
set formatoptions=qrn1tc
set colorcolumn=+1
set list
setglobal number
setglobal rnu
set cinoptions=(0,u0,U0,t0,g0,N-s
let g:load_doxygen_syntax=1
set mouse=a
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
" Tabs {{{
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
" }}}
" Automatic file saving on focus lost {{{
au FocusLost * :wa
au FocusLost,TabLeave * call feedkeys("\<C-\>\<C-n>")
" }}}
" }}}
" Leaders ----------------------------------------------------------------- {{{
let mapleader = ","
let maplocalleader = "\\"
" }}}
" Basic shortcuts --------------------------------------------------------- {{{
" Open a vertical split
nnoremap <leader>w <C-w>v<C-w>l
" Open an horizontal split.
nnoremap <leader>e :split<CR>
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" Select whole file
nnoremap <leader>vf ggVG
" And make j and k works
nnoremap j gj
nnoremap k gk
" Save my cap key
nmap ; :
" $ and ^ are too far
noremap L $
noremap H ^
noremap K <C-U>
noremap J <C-D>
" Activate <tab> to switch between brackets
nnoremap <tab> %
vnoremap <tab> %
" Easy buffer navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
noremap <C-n> :bnext<CR>
noremap <C-b> :bprev<CR>
map <leader>w <C-w>v<C-w>l
" Easy replacement
nnoremap <leader>s :%s//g<left><left>
" Bind [ and ] to ^ and $ for an easier navigation
nmap <leader>[ ^
nmap <leader>] $
" Redo
nnoremap U <C-r>
" Close that window
noremap <leader>Q :q<CR>
" Open file
nnoremap <leader>o <C-w><C-v><C-l>:CtrlP<CR>
" Remove the word under the cursor
nnoremap <leader>d diw
" Select (linewise) the text you just pasted (handy for modifying indentation)
nnoremap <leader>v V`]
" Save my life.
cnoreabbrev W w
" List the fixmes/todos in the current directory.
nnoremap <leader>0 :Ag /TODO\\|FIXME/ **/*<CR>:cw<CR>
" Searching {{{
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
" Remove highlight for the current search
nnoremap <leader><space> : noh<cr>
" }}}
" }}}
" Edition commands -------------------------------------------------------- {{{
" Fill rest of line with characters {{{
function! FillLine( str )
" set tw to the desired total length
let tw = &textwidth
if tw==0 | let tw = 80 | endif
" strip trailing spaces first
.s/[[:space:]]*$//
" calculate total number of 'str's to insert
let reps = (tw - col("$")) / len(a:str)
" insert them, if there's room, removing trailing spaces (though forcing
" there to be one)
if reps > 0
.s/$/\=(' '.repeat(a:str, reps))/
endif
endfunction
" Fill the current line with dashes and replace the last 4 characters by
" markers.
nnoremap <leader>K mq:call FillLine('-')<cr>`qA<esc>xxxxa {<esc>a{{<esc>
nnoremap <leader>k mq:call FillLine('-')<cr>`qA
" }}}
" }}}
" Visual ------------------------------------------------------------------ {{{
" (this title is probably poorly choosen)
" Spellcheking
highlight SpellBad term=underline gui=undercurl
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" }}}
" }}}
" Plugins ----------------------------------------------------------------- {{{
" Ctrl-P {{{
nnoremap <leader>p :CtrlP<CR>
" }}}
" Scratch {{{
nnoremap <leader><tab> :Scratch<CR>
inoremap <leader><tab> <Esc>:Scratch<CR>i
" }}}
" Syntastic {{{
let g:syntastic_cpp_compiler='clang++'
let g:syntastic_cpp_compiler_options=' -std=c++11 -Wall -Wextra -Weverything'
" }}}
" }}}
" File type-specific configuration ---------------------------------------- {{{
" C {{{
" This respects EPITA's C / C++ coding style.
" The following rules are based on the vim plugin for the FreeBSD coding style:
" http://svn0.us-east.freebsd.org/base/head/tools/tools/editing/freebsd.vim
" Ignore indents caused by parentheses in FreeBSD style.
function! IgnoreParenIndent()
let indent = cindent(v:lnum)
if indent > 4000
if cindent(v:lnum - 1) > 4000
return indent(v:lnum - 1)
else
return indent(v:lnum - 1) + 4
endif
else
return (indent)
endif
endfun
autocmd FileType c set tabstop=4
autocmd FileType c set shiftwidth=4
autocmd FileType c set softtabstop=4
autocmd FileType c set comments=sl:/**,mb:**,elx:*/
autocmd FileType cpp set comments=sl:/**,mb:**,elx:*/
autocmd FileType c set cindent
autocmd FileType c set cinoptions=(4200,u4200,+0.5s,*500,:0,t0,U4200
autocmd FileType c set indentexpr=IgnoreParenIndent()
autocmd FileType c set indentkeys=0{,0},0),:,0#,!^F,o,O,e
let g:load_doxygen_syntax=1
" }}} --------------------------------------------------------------------------
" Javascript {{{
autocmd FileType javascript set tw=80
" }}}
" }}}
" GUI-specific configuration ---------------------------------------------- {{{
if has('gui_running')
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set guicursor=n-c:block-Cursor-blinkon0
set guicursor+=v:block-vCursor-blinkon0
set guicursor+=i-ci:ver20-iCursor-blinkwait10-blinkon500-blinkoff300
endif
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment