" Standard setup {{{1 " set non-compatible set nocompatible " set syntax highlighting syntax on " Enable netrw filetype plugin indent on " start pathogen call pathogen#infect() call pathogen#helptags() "Leaders {{{1 let mapleader = "\" let maplocalleader = "\\" " Config {{{1 " Set auto read so a file is updated if externally changed set autoread " Turn on mouse Interaction " set mouse=a " Set spelcheck language set spelllang=en_gb " Set default split to be right or bottom set splitright set splitbelow " Generally, I want my text width to be 80 set textwidth=80 " Set my colourscheme " " Access colors present in 256 colorspace let base16colorspace=256 " Set my colourscheme colorscheme base16-gruvbox-dark-hard if exists('+colorcolumn') augroup colorcols autocmd! autocmd VimEnter,BufEnter,FocusGained,WinEnter * let &l:colorcolumn='+' . join(range(1,254),',+') autocmd WinLeave,FocusLost * let &l:colorcolumn='' . join(range(0,254),',') augroup END endif " Tell vim it's a fast terminal set ttyfast " set relative ruler with current line as real line number set relativenumber set number " Stop vim wrapping a line mid-word set linebreak " search in sub folders set path+=** " Display matching files when tab completing - ignoring files that I probably " dont want to match set wildmenu set wildignore+=*.min.js,*.min.css,*/node_modules/*,*/dist/* " Allows vim to background buffers without saving set hidden " Time vim waits to see if you are pushing another key set timeoutlen=500 " set tabwidth set autoindent set smartindent set shiftwidth=4 set tabstop=4 " Add invisivle character reperesentation set list listchars=tab:»\ ,trail:\␣,eol:↩ " make search highlight as you type set incsearch " Make search case insensitive unless I type a capital letter set ignorecase smartcase " Make backspace work properly in insert mode set backspace=indent,eol,start " Show commands as you type them set showcmd " Highlighting the current line set cursorline " Make vim default to the plus register (system clipboard) when yanking etc. "set clipboard=unnamedplus " Make the cursor change in insert mode "Ps = 0 -> blinking block. "Ps = 1 -> blinking block (default). "Ps = 2 -> steady block. "Ps = 3 -> blinking underline. "Ps = 4 -> steady underline. "Ps = 5 -> blinking bar (xterm). "Ps = 6 -> steady bar (xterm). let &t_SI = "\e[5 q" let &t_EI = "\e[1 q" " reset cursor on start " In zsh I have a bar when in insert mode and a box when in visual. I want " vim to automatically switch to a box when I open it augroup cursorToBox au! autocmd VimEnter * silent !echo -ne "\e[1 q" augroup END " Makes vim try to keep 5 lines visible at the top and bottom set scrolloff=5 " Highlighting {{{1 " background {{{2 highlight Normal guibg=NONE ctermbg=NONE " Spell {{{2 highlight clear SpellBad highlight SpellBad cterm=underline ctermfg=red highlight clear SpellRare highlight SpellRare cterm=underline ctermfg=yellow highlight clear SpellLocal highlight SpellLocal cterm=underline ctermfg=yellow " Plugin Options {{{1 " Airline set laststatus=2 let g:airline_powerline_fonts = 1 let g:airline_theme='base16' " Vimtex let g:tex_flavor='latex' let g:vimtex_view_method='zathura' let g:vimtex_quickfix_mode=0 set conceallevel=1 let g:tex_conceal='abdmg' " Tables let g:table_mode_corner_corner='+' let g:table_mode_header_fillchar='=' " UtiliSnips let g:UltiSnipsExpandTrigger="" let g:UltiSnipsEditSplit="vertical" " Lion let g:lion_squeeze_spaces = 1 " FZF " Prefixes all of the fzf commands let g:fzf_command_prefix = 'Fzf' " Mappings for common Fzf commands nnoremap f = :FzfFiles nnoremap b = :FzfBuffers nnoremap h = :FzfHelptags " Space is important at the end of this command nnoremap / = :FzfRg " deoplete " If I am running neovim, I want deoplete to start if has('nvim') let g:deoplete#enable_at_startup = 1 endif "}}} " Functions {{{1 function! NewHtml() read ~/Templates/html normal! ggdd setlocal filetype=html endfunction function! NewLatex() read ~/Templates/latex normal! ggdd setlocal filetype=tex endfunction function! NewShellscript() read ~/Templates/boilerplate.sh normal! ggdd setlocal filetype=bash endfunction " Moves to open window, or focuses it " https://www.reddit.com/r/vim/comments/8f80o3/awesome_way_to_navigate_windows_and_autocreate/ function! WinMove(key) let t:curwin = winnr() exec "wincmd ".a:key if (t:curwin == winnr()) if (match(a:key,'[jk]')) wincmd v else wincmd s endif exec "wincmd ".a:key endif endfunction " Commands {{{1 "gets the wp salts command! WpSalts :r! curl https://api.wordpress.org/secret-key/1.1/salt 2> /dev/null " Mappings {{{1 " Move lines up/down or chars left/right using arrow keys nnoremap ddp nnoremap ddkP nnoremap xp nnoremap xhP " Maps the semi colon to colon in normal mode nnoremap ; : nnoremap : ; " Maps the semi colon to colon in visual mode vnoremap ; : vnoremap : ; " Compiles documents " The uppercase versions don't push enter an extra time resulting in seeing " the output of the compile command. Useful for debugging nnoremap cc :w! \| !compiler % nnoremap cC :w! \| !compiler % nnoremap cl :w! \| !compiler % letter nnoremap cL :w! \| !compiler % letter " Opens the compiled documents " If something like html, it doesn't need to be compiled first nnoremap co :!opout % " Activate spelling nnoremap :set spell! " Disable Scroll wheel noremap noremap " make ctrl + hjkl move + create windows nnoremap :call WinMove('h') nnoremap :call WinMove('j') nnoremap :call WinMove('k') nnoremap :call WinMove('l') " Make Ctrl C and Ctrl V work on system clipboard " if in visual or insert mode respectively vnoremap "+y inoremap "+pa " Make Ctrl t open new tab " nnoremap :tabnew " map gV to select previously pasted nnoremap gV "`[".getregtype(v:register)[0]."`]" " Makes :w1 work the same as :w! (saves pushing the shift key) cnoremap w1 w! " Same for quitting cnoremap q1 q! cnoremap qa1 qa! " Set :w!! to save with sudo cnoremap w!! w !sudo tee % " The same but without shift cnoremap w11 w !sudo tee % "Run current line as command nnoremap q !!$SHELL vnoremap q !$SHELL " Do Shebang line " inoremap :sil exe ".!which " s/^/#!/ filetype detectYpDi inoremap :sil s/^/#!\/usr\/bin\/env / filetype detect:nohlYpDi " Makes leader+s replace on the current wordd nnoremap s :%s/=expand('')//g " Do bullet points inoremap :exe "norm Ypf lDB\"A " edit vimrc nnoremap ev :vsplit $MYVIMRC nnoremap sv :source $MYVIMRC " add new line without entering insert mode nnoremap o nnoremap O " Make jj in insert mode go to normal mode inoremap jj " Fix previous spelling mistake in insert mode inoremap u[s1z=`]au " Makes capital hjkl work as extream versions nnoremap H ^ vnoremap H ^ nnoremap L $ vnoremap L $ nnoremap J 5j vnoremap J 5j nnoremap K 5k vnoremap K 5k " Get back old functionality using leader nnoremap H H vnoremap H H nnoremap l L vnoremap l L nnoremap j J vnoremap j J " Since H and L are now h/l, also do the same for M nnoremap m M vnoremap m M function! s:make_email_list(lines) let l:emails = [] "return type( a:lines ) for email in a:lines let l:address = substitute(split( email, "\t" )[0], " ","","" ) let l:name = split( email, "\t" )[1] let l:emails = add( l:emails, l:name . " <" . l:address . ">" ) endfor return join(l:emails, ', ') endfunction inoremap fzf#vim#complete({ \ 'source': '$HOME/Contacts/lookup', \ 'reducer': function('make_email_list'), \ 'options': '--multi', \ 'down': '30%' }) " Stops vim doing anything when terminal gains or looses focus noremap [I noremap [O noremap! [I noremap! [O " Url encode and decode current selection vnoremap u :B !urlencode vnoremap U :B !urldecode " File Type Specific {{{1 "Make web files fold on indent {{{2 augroup file_web autocmd! autocmd FileType html,xhtml,css,less,javascript,php setlocal foldmethod=indent "foldenable augroup END " js maps {{{2 augroup javascript autocmd! "binds this in class autocmd FileType javascript nnoremap b Ithis.^y$$a = pa.bind(this); augroup END " " email maps {{{2 augroup mail autocmd! "binds this in class autocmd FileType mail setlocal spell augroup END " less maps {{{2 augroup css autocmd! "binds this in class autocmd FileType less nnoremap cl :w! \| !compiler styles.less autocmd FileType less nnoremap cL :w! \| !compiler styles.less autocmd FileType less vmap a gL: augroup END " Add Html maps, Currently only pandoc conversion {{{2 augroup html autocmd! " Run current line through pandoc. " Convert from markdown to html autocmd FileType html nnoremap p :.!pandoc -t html -f markdown-auto_identifiers --wrap=preserve "convert from html to markdown autocmd FileType html nnoremap P :.!pandoc -t markdown -f html --wrap=preserve --atx-headers "Run current selection through pandoc " Convert from markdown to html autocmd FileType html vnoremap p :!pandoc -t html -f markdown-auto_identifiers --wrap=preserve "convert from html to markdown autocmd FileType html vnoremap P :!pandoc -t markdown -f html --wrap=preserve --atx-headers augroup END " Add latex maps, Currently only pandoc conversion {{{2 augroup latex autocmd! autocmd FileType tex,latex setlocal spell autocmd FileType tex,latex setlocal textwidth=100 " Run current line through pandoc. " Convert from markdown to latex autocmd FileType tex,latex nnoremap p :.!pandoc -t latex -f markdown-auto_identifiers --wrap=preserve "convert from latex to markdown autocmd FileType tex,latex vnoremap P :.!pandoc -t markdown -f latex --wrap=preserve --atx-headers "Run current selection through pandoc " Convert from markdown to latex autocmd FileType tex,latex vnoremap p :!pandoc -t latex -f markdown-auto_identifiers --wrap=preserve "convert from latex to markdown autocmd FileType tex,latex vnoremap P :!pandoc -t markdown -f latex --wrap=preserve --atx-headers augroup END " Make vim fold using markers {{{2 augroup file_i3 autocmd! autocmd FileType i3config setlocal foldmethod=marker "foldenable augroup END " Make vim fold using markers {{{2 augroup file_vim autocmd! autocmd FileType vim setlocal foldmethod=marker "foldenable augroup END " Make json fold using syntax {{{2 augroup file_json autocmd! autocmd FileType json setlocal foldmethod=syntax "foldenable augroup END " Make md files use spellcheck{{{2 augroup file_md autocmd! autocmd FileType markdown setlocal textwidth=100 autocmd FileType markdown setlocal spell augroup END ""set es6 files to javascript {{{2 augroup detectES6 autocmd! autocmd BufNew,BufNewFile,BufRead *.es6 :setlocal filetype=javascript augroup END ""set htaccess variations to apache {{{2 augroup detectHtaccess autocmd! autocmd BufNew,BufNewFile,BufRead *.htaccess,*.localhtaccess,*.livehtaccess :setlocal filetype=apache augroup END