"#commands{{{ " TrimWhitespace{{{ command! -range=% TrimWhitespace let b:wv = winsaveview() | \ keeppattern ,s/\s\+$// | \ call winrestview(b:wv) "}}} " Scratch, ScratchVertical{{{ command! Scratch new | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile "}}} "}}} " #settings {{{ scriptencoding utf-8 syntax on set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:\ " persisitent undo file set undofile set undodir=~/.vim/.vimtmp set backupdir=~/.vim/.vimtmp set directory=~/.vim/.vimtmp set viewoptions-=options set title set ignorecase set smartcase set wildmenu set wildmode=longest:full,full set wildignore+=/node_modules/,dist/ " Use ag over grep if executable('ag') set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ node_modules endif colorscheme peachpuff set hidden set hlsearch set completeopt=menuone set nospell set spelllang=en_gb set diffopt+=vertical set rnu nu set tabstop=8 set softtabstop=2 set shiftwidth=2 set shiftround set expandtab set autoindent set textwidth=120 set formatoptions=cq set wrapmargin=0 set nocursorline set iskeyword+=- set showcmd set incsearch set laststatus=2 set shortmess=aoOT set foldmethod=indent set showmode set autoindent set breakindent set showbreak=\ \ ↳\ set mouse=a set listchars=eol:¬,tab:>-,trail:~,extends:>,precedes:<,space:· set foldtext=MyFoldText() set conceallevel=0 "----------------------------------------------------------------------------}}} " #mappings {{{ let g:mapleader = ' ' " #syntax nnoremap s :syntax on nnoremap S :syntax off " miscallaneous {{{ nnoremap 0 ^ nnoremap cs :let @/="" nnoremap : :setlocal number: nnoremap rc :so $MYVIMRC nnoremap nh (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n" nnoremap sl :set invlist nnoremap aa A nnoremap a2 A nnoremap ab AB nnoremap co :!clear; nnoremap ;; A; nnoremap ;j jA; nnoremap ,, A, nnoremap ,j jA, " Focus on current fold, close the rest nnoremap zz zMzvzt " replace current word with last yanked/deleted text nnoremap rw "_diwP " replace current word with last yanked text nnoremap ry diw"0P " quick grep of visual selection vnoremap gr y:grep! -R " . " open quickfix window of TODOs " FIXME i want fixme!!! nnoremap td :grep -RE '(TODO\\|FIXME)' .:botright cwindow:echo len(getqflist()) 'TODOs' " devdocs mapping nnoremap dd :DD " write and delete current buffer nnoremap bx :w\|bd " sync highlighting from start nnoremap ss :syntax sync fromstart "}}} " terminal{{{ if has('terminal') tnoremap endif "}}} " windows{{{ nnoremap ww :resize:vertical resize " }}} " git mappings {{{ " also see vim-fugitive plugin section nnoremap gD :!clear; echo 'git diff'; git diff nnoremap ga :!clear; git add %; git status nnoremap gA :!clear; git add .; git status nnoremap gg :!clear; git add %; git commit -m '' nnoremap gP :!clear; echo 'git push'; git push "}}} " movement/navigation{{{ nnoremap j :resize -5 nnoremap k :resize +5 nnoremap l :vertical resize +5 nnoremap h :vertical resize -5 " alias for :tjump nnoremap tj g " alias for :ptjump nnoremap tp g} "}}} " location list and quickfix mappings {{{ nnoremap lo :botright lwindow nnoremap :lprevzv nnoremap :lnextzv nnoremap lc :lclose nnoremap lh :lhistory nnoremap lp :lolder nnoremap ln :lnewer nnoremap qo :botright cwindow nnoremap :cprevzv nnoremap :cnextzv nnoremap qc :cclose nnoremap qh :chistory nnoremap qp :colder nnoremap qn :cnewer "}}} " insert mode mappings {{{ inoremap jkrg :reg inoremap :w :w inoremap [:w :w inoremap {:w :w " working_with_underscores{{{ nnoremap w f_l nnoremap b hT_ nnoremap e lt_ onoremap u t_ onoremap U f_ "}}} "----------------------------------------------------------------------------}}} augroup gitcommit autocmd! autocmd FileType gitcommit 1 augroup END " vim: set foldmethod=marker: " #mappings {{{ " #mappings {{{ "