""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Custom Config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set cursorline set number set relativenumber set showcmd set nowrap set nostartofline set sidescroll=1 set sidescrolloff=999 " general function! Bye() if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 :quit else :bdelete endif endfunction nnoremap :call Bye() nnoremap , :.terminal ++noclose vnoremap , :terminal ++noclose nnoremap < :%terminal ++noclose nnoremap W :set wrap! nnoremap T :vertical terminal nnoremap u :set clipboard=unnamedplus nnoremap ddkP nnoremap ddp nnoremap R :read ! nnoremap P :r !xsel -ob " move nnoremap } nnoremap { inoremap cnoremap cnoremap nmap H 0 nnoremap L $ nnoremap 60l nnoremap 60h " disable syntax nnoremap s \ : if exists("syntax_on") \ syntax off \ else \ syntax enable \ endif " show current syntax nnoremap S :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')),' ') " Operator pending onoremap p i( onoremap ap a( " next parenthesis onoremap fp :normal! f(vi( onoremap b i{ onoremap fb :normal! f{vi{ onoremap ab a{ " block onoremap B /return " Search vnoremap // y/\V=escape(@",'/\')'") " S&R nnoremap ; :%s:::g vnoremap ; :s:::g cnoremap \\ \(\) " Fix paste bug triggered by inoremaps set t_BE= " surround with '' or "" vnoremap ' ``>la' vnoremap " ``>la" vnoremap ( ``>la) vnoremap { ``>la} vnoremap [ ``>la] " abbrev iabbrev @@ typebrook@gmail.com " vim_markdown let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_conceal = 0 vnoremap ``>la]()i " shell script autocmd FileType sh set shiftwidth=2 " XML fold let g:xml_syntax_folding=1 autocmd FileType xml setlocal foldmethod=syntax " JSON fold let g:json_syntax_folding=1 autocmd FileType json setlocal foldmethod=syntax """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Settings for Vimwiki """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" nnoremap tt :VimwikiTable nnoremap wg :VimwikiGoto nnoremap wT :VimwikiSearchTags nnoremap i I- l nnoremap I :s/^[ ]*- \(\[.\] \)*// nmap D dd:VimwikiMakeDiaryNoteGp:w!:Bclose vnoremap D d:VimwikiMakeDiaryNoteGp:w! let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}] " Git push quietly whenever leaving vim with VimWiki files augroup vimwikiPush autocmd! autocmd VimLeave ~/vimwiki/* :!(cd ~/vimwiki && git add * && git commit -am update && git push origin > /dev/null 2>&1 &) augroup END " Configuration fro vim-instant-markdown let g:instant_markdown_autostart = 0 nnoremap md :InstantMarkdownPreview """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Redirect the output of a Vim or external command into a scratch buffer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Copy from : https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 " " Usage: " :Redir hi ............. show the full output of command ':hi' in a scratch window " :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window function! Redir(cmd) for win in range(1, winnr('$')) if getwinvar(win, 'scratch') execute win . 'windo close' endif endfor if a:cmd =~ '^!' let output = system(matchstr(a:cmd, '^!\zs.*')) else redir => output execute a:cmd redir END endif vnew let w:scratch = 1 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile call setline(1, split(output, "\n")) endfunction command! -nargs=1 -complete=command Redir silent call Redir() nnoremap r :Redir """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Make Alt key works on Gnome terminal """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Solution is here: https://stackoverflow.com/questions/6778961 let c='a' while c <= 'z' exec "set =\e".c exec "imap \e".c." " let c = nr2char(1+char2nr(c)) endw set timeout ttimeoutlen=50 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => vim-racer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set hidden let g:racer_cmd = "~/.cargo/bin/racer" let g:racer_experimental_completer = 1 autocmd FileType rust nmap gd (rust-def) autocmd FileType rust nmap gs (rust-def-split) autocmd FileType rust nmap gx (rust-def-vertical) autocmd FileType rust nmap gd (rust-doc) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => vim-plug """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " run :PlugInstall to install plugins call plug#begin('~/.vim/plugged') " Add indent line Plug 'Yggdroot/indentLine' Plug 'mileszs/ack.vim' Plug 'tpope/vim-surround' Plug 'lifepillar/pgsql.vim' Plug 'vimwiki/vimwiki' Plug 'iberianpig/tig-explorer.vim' Plug 'rust-lang/rust.vim' Plug 'racer-rust/vim-racer' Plug 'suan/vim-instant-markdown', {'for': 'markdown'} " Initialize plugin system call plug#end()