1 set nocompatible " be iMproved 2 3 set t_Co=256 4 syntax on 5 filetype off 6 7 filetype plugin indent on 8 set tabstop=4 9 set shiftwidth=4 10 set backspace=indent,eol,start 11 set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P 12 set ruler 13 colorscheme xoria256 14 "colorscheme molokai 15 16 " Vim - remap help to open in a vertical buffer as opposed to a horizontal 17 " buffer. Wasted space and hard to use the default way. 18 "cnoremap help vert help 19 " Vim - I like opening help in new tabs now. 20 cnoremap help tab help 21 " Vim - move between buffers with hotkeys. Ctrl+(left/right). 22 map <C-Right> :bnext<CR> 23 map <C-Left> :bprev<CR> 24 map <C-h> :bprev<CR> 25 map <C-l> :bnext<CR> 26 27 " When a line is wrapped, treat it as multiple lines when moving with up and 28 " down. 29 map <silent> <UP> g<UP> 30 map <silent> <DOWN> g<DOWN> 31 map <silent> j gj 32 map <silent> k gk 33 34 " Unbind arrow keys in normal mode. 35 noremap <Up> <NOP> 36 noremap <Down> <NOP> 37 noremap <Left> <NOP> 38 noremap <Right> <NOP> 39 40 " Visual bell is annoying, and I imagine sounds would be too if I had them on. 41 set noerrorbells 42 set novisualbell 43 44 " The wildmenu is cool. See help page. 45 set wildmenu 46 " Ignore compiled files when using the wildmenu. (Will probably add more) 47 set wildignore=*.o,*.so,*.pyc 48 " This does tab completion like the normal shell does, keep going until a 49 " conflict. I shall use the default, which is like Windows Command Prompt. 50 "set wildmode=longest:full 51 52 " Use VERY MAGIC with vim search and replaces. See 'magic' in help. 53 " Normally I need to escape regex stuff like captures (), and pipes. 54 " All ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have 55 " a special meaning in very magic mode. 56 :cnoremap s/ s/\v 57 58 " Return to previous file location after closing vim. 59 autocmd BufReadPost * 60 \ if line("'\"") > 0 && line("'\"") <= line("$") | 61 \ exe "normal! g`\"" | 62 \ endif 63 64 " Apparently vim has spellcheck. 65 map ss :setlocal spell!<cr> 66 67 " Show tabs and trailing characters. 68 set list 69 set listchars=tab:>-,trail:- 70 71 " This makes it keep X lines at the top and bottom before scrolling. This 72 " helps keep some context. Note that this does cause H and L (they go to the 73 " top and bottom of the current page respectively) to go nearest to top and bottom 74 " before the page would start scrolling. That is H and L now go X lines from 75 " the top and bottom. 76 set scrolloff=10 77 78 " This shows the current command you are entering near the bottom right. 79 set showcmd 80 81 " Search options. ignorecase=thisisobvious, smartcase only is case sensitive 82 " if a capital letter is present. 83 set ignorecase 84 set smartcase 85 86 " The combo of 'set number' and 'set relativenumber' ends up setting 87 " relative numbers, but where it would say line 0 for relative numbers, 88 " shows the actual line number. The F5 remapping causes it to toggle from 89 " absolute line numbers to relative with the actual line number at the current 90 " line. 91 set number 92 set relativenumber 93 nnoremap <silent> <F5> :set relativenumber!<CR> 94 95 " Disable folding, I don't need it very often. 96 set nofoldenable 97 98 """ Auto complete closing characters, from vim wikia. 99 " Curly braces. 100 inoremap { {}<Left> 101 inoremap {<CR> {<CR>}<Esc>O 102 " Parentheses 103 inoremap ( ()<Left> 104 inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")" 105 106 " In many terminal emulators the mouse works just fine, thus enable it. 107 if has('mouse') 108 set mouse=a 109 endif 110 111 " Need to include 'stty -ixon' in .bashrc or .zshrc for this to work. 112 " Ctrl-S will save the file. 113 inoremap <silent><C-S> <C-O>:update<CR> 114 nnoremap <silent><C-S> :update<CR> 115 inoremap <silent>jk <esc> 116 inoremap <silent>fd <esc> 117 noremap <silent>; : 118 set nowrap 119 " Y by default does not work from current position to the end of the 120 " line like D or C does. So change that. 121 nnoremap Y y$ 122 123