diff options
Diffstat (limited to 'vim/.vim/vimrc')
| -rw-r--r-- | vim/.vim/vimrc | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc new file mode 100644 index 0000000..52f1be7 --- /dev/null +++ b/vim/.vim/vimrc | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | silent! execute pathogen#infect() | ||
| 2 | |||
| 3 | """ DEFAULT VIM SETTINGS | ||
| 4 | |||
| 5 | " Reload vimrc on save | ||
| 6 | augroup reload_vimrc " { | ||
| 7 | autocmd! | ||
| 8 | autocmd BufWritePost $MYVIMRC source $MYVIMRC | ||
| 9 | augroup END " } | ||
| 10 | |||
| 11 | let mapleader=" " | ||
| 12 | |||
| 13 | syntax on | ||
| 14 | filetype plugin indent on | ||
| 15 | |||
| 16 | " Set colorscheme when the terminal has 256 color support | ||
| 17 | try | ||
| 18 | if (&t_Co == 256) && match($TERM, "256color") >= 0 | ||
| 19 | colorscheme Benokai | ||
| 20 | else | ||
| 21 | throw "nocolor" | ||
| 22 | endif | ||
| 23 | catch | ||
| 24 | colorscheme desert | ||
| 25 | endtry | ||
| 26 | |||
| 27 | " Some vim settings | ||
| 28 | set number | ||
| 29 | set relativenumber | ||
| 30 | set list | ||
| 31 | set modeline | ||
| 32 | set background=dark | ||
| 33 | set foldmethod=indent | ||
| 34 | set listchars=trail:·,tab:▸\ ,eol:¬ | ||
| 35 | set scrolloff=1 | ||
| 36 | set backspace=indent,eol,start | ||
| 37 | set cursorline | ||
| 38 | |||
| 39 | " Search-related things | ||
| 40 | set hlsearch "highlight search result | ||
| 41 | set incsearch " incremental search | ||
| 42 | set ignorecase | ||
| 43 | set smartcase " capital letters = case sensitive | ||
| 44 | |||
| 45 | " Disable ex mode | ||
| 46 | nnoremap Q <Nop> | ||
| 47 | |||
| 48 | " Save as sudo | ||
| 49 | cnoremap w!! w !sudo tee > /dev/null % | ||
| 50 | |||
| 51 | " Remove training spaces on save | ||
| 52 | autocmd BufWritePre * :%s/\s\+$//e | ||
| 53 | |||
| 54 | " Switch windows with <C-W>[direction] | ||
| 55 | nnoremap <C-J> <C-W>j | ||
| 56 | nnoremap <C-K> <C-W>k | ||
| 57 | nnoremap <C-H> <C-W>h | ||
| 58 | nnoremap <C-L> <C-W>l | ||
| 59 | |||
| 60 | " Never use the arrow keys | ||
| 61 | inoremap <Up> <Nop> | ||
| 62 | inoremap <Down> <Nop> | ||
| 63 | inoremap <Left> <Nop> | ||
| 64 | inoremap <Right> <Nop> | ||
| 65 | noremap <Up> <Nop> | ||
| 66 | noremap <Down> <Nop> | ||
| 67 | noremap <Left> <Nop> | ||
| 68 | noremap <Right> <Nop> | ||
| 69 | |||
| 70 | " Append modeline when pressing <leader> ml | ||
| 71 | function! AppendModeline() | ||
| 72 | let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", | ||
| 73 | \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') | ||
| 74 | let l:modeline = substitute(&commentstring, "%s", l:modeline, "") | ||
| 75 | call append(line("$"), l:modeline) | ||
| 76 | endfunction | ||
| 77 | nnoremap <silent> <Leader>ml :call AppendModeline()<CR> | ||
| 78 | |||
| 79 | " NeoVIM specifics | ||
| 80 | if has('nvim') | ||
| 81 | nmap <BS> <C-W>h | ||
| 82 | tnoremap <Esc> <C-\><C-n> | ||
| 83 | endif | ||
| 84 | |||
| 85 | """ PLUGIN SPECIFIC SETTINGS | ||
| 86 | |||
| 87 | if exists("g:loaded_pathogen") | ||
| 88 | |||
| 89 | " NERDTree: | ||
| 90 | " Open NERDTree when no file is specified | ||
| 91 | autocmd StdinReadPre * let s:std_in=1 | ||
| 92 | autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | ||
| 93 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | ||
| 94 | |||
| 95 | " Airline: | ||
| 96 | " On arch linux install the following: | ||
| 97 | " otf-powerline-symbols-git | ||
| 98 | " powerline-fonts-git | ||
| 99 | let g:airline_powerline_fonts = 1 | ||
| 100 | if !exists('g:airline_symbols') | ||
| 101 | let g:airline_symbols = {} | ||
| 102 | endif | ||
| 103 | let g:airline_symbols.space = "\ua0" | ||
| 104 | set laststatus=2 | ||
| 105 | |||
| 106 | endif | ||
| 107 | |||
| 108 | " vim: set ts=8 sw=4 tw=0 et : | ||
