" Visual settings set t_Co=16 set bg=dark set number highlight LineNr ctermfg=darkgrey " Syntax highlighting syntax on set hlsearch " Case insensitive search (except for when explicitly using uppercase letters) set ignorecase set smartcase " Indentation options (yeah let's switch to spaces instead of tabs I guess...) set autoindent set expandtab set smarttab set shiftwidth=4 set tabstop=4 set softtabstop=4 " Activate filetype plugin (e.g. for automatically using tabs instead of spaces in Makefiles) filetype plugin on " Syntax rules for custom file extensions/patterns autocmd BufNewFile,BufRead *.gitconfig set syntax=gitconfig autocmd BufNewFile,BufRead *.rasi set syntax=scss " Indentation for Python (use 4 spaces) "autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4 autocmd FileType yml,yaml setlocal ts=2 sts=2 sw=2 expandtab " Indentation (don't remove tabs from empty lines) "inoremap x "nnoremap o ox "nnoremap O Ox " Mouse settings set mouse=a " Disable beeping on console set belloff=all " Do not insert comment leader when entering insert mode with 'o'/'O' in comment line autocmd BufNewFile,BufRead * set formatoptions-=o " clang autocomplete: do not open completion box automatically let g:clang_complete_auto=0 " Disable middle mouse button paste when in normal mode map map <2-MiddleMouse> map <3-MiddleMouse> map <4-MiddleMouse> " Keyboard mappings " ----------------- nnoremap :nohl:diffupdate set pastetoggle= " Toggle line numbers nnoremap :set number! " If the current buffer has never been saved, it will have no name, " call the file browser to save it, otherwise just save it. command! -nargs=0 -bar Update if &modified \| if empty(bufname('%')) \| browse confirm write \| else \| confirm write \| endif \|endif " Bind to save nnoremap :Update inoremap :Update " sudo-write with :w!! cnoremap w!! w !sudo tee >/dev/null % " Edit (\ev) and reload (\rv) .vimrc (reload .gvimrc if running gvim) nnoremap ev :split $MYVIMRC if has('gui_running') nnoremap rv :source $MYVIMRC:source $MYGVIMRC else nnoremap rv :source $MYVIMRC endif " Split line at cursor with (as opposite of for join lines) nnoremap ik$ " Easier buffer switching " ----------------------- " Mappings to access buffers (don't use "\p" because a " delay before pressing "p" would accidentally paste). " \l : list buffers " \b \n \g : go back/forward/last-used " \1 \2 \3 : go to buffer 1/2/3 etc nnoremap l :ls nnoremap b :bp nnoremap n :bn nnoremap g :e# nnoremap 1 :1b nnoremap 2 :2b nnoremap 3 :3b nnoremap 4 :4b nnoremap 5 :5b nnoremap 6 :6b nnoremap 7 :7b nnoremap 8 :8b nnoremap 9 :9b nnoremap 0 :10b " Compiling and making nnoremap :up:make:redraw! \| cw nnoremap :up:make run:redraw! \| cw " Tab buffers nnoremap :tab ball " Tab movement noremap :-tabmove noremap :+tabmove " -- Shortcuts for insert mode " Exit insert mode imap ,, imap jk inoremap " Quick movement with Alt-h/j/k/l inoremap h inoremap j inoremap k inoremap l " Unindent with Shift-Tab inoremap << " Copy and to X clipboard (Ctrl-C in visual mode and Ctrl-V in insert mode) vmap "+y imap "+P " Undo in insert mode with Ctrl-U imap u " Quick exit map Q :qa " Because I always type q: too fast, which opens the command history... map q: :q