" 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 " 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 set wildmenu " 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 " Make vim default to the plus register (system clipboard) when yanking etc. "set clipboard=unnamedplus " Plugin Options {{{1 let g:cssColorVimDoNotMessMyUpdatetime = 1 " Airline set laststatus=2 let g:airline_powerline_fonts = 1 let g:airline_theme='dark' " Vimtex let g:vimtex_view_method = 'zathura' " Emmet let g:user_emmet_leader_key="" let g:user_emmet_install_global = 0 " Quick tex options {{{2 " HTML {{{3 let g:quicktex_html = { \' ' : "\/<+.*+>\\"_c/+>/e\", \';b' : "<+++> <++>", \';i' : "<+++> <++>", \';1' : "

<+++>

<++>", \';2' : "

<+++>

<++>", \';3' : "

<+++>

<++>", \';p' : "

<+++>

<++>", \';a' : "\"><+++> <++>", \';ul' : "
    \
  • <+++>
  • \
\\<++>", \';ol' : "
    \
  1. <+++>
  2. \
\\<++>", \';li' : "
  • <++>
  • ", \} " CSS {{{3 let g:quicktex_css = { \' ' : "\/<+.*+>\\"_c/+>/e\", \ \'w' : "width: <+++>;\<++>", \'h' : "height: <+++>;\<++>", \'mw' : "max-width: <+++>;\<++>", \'mh' : "max-height: <+++>;\<++>", \'t' : "top: <+++>;\<++>", \'b' : "bottom: <+++>;\<++>", \'l' : "left: <+++>;\<++>", \'r' : "right: <+++>;\<++>", \'pos' : "position: <+++>;\<++>", \ \'m' : "margin: <+++>;\<++>", \'mt' : "margin-top: <+++>;\<++>", \'mb' : "margin-bottom: <+++>;\<++>", \'ml' : "margin-left: <+++>;\<++>", \'mr' : "margin-right: <+++>;\<++>", \ \'p' : "padding: <+++>;\<++>", \'pt' : "padding-top: <+++>;\<++>", \'pb' : "padding-bottom: <+++>;\<++>", \'pl' : "padding-left: <+++>;\<++>", \'pr' : "padding-right: <+++>;\<++>", \ \'bor' : "border: <+++>;\<++>", \'bort' : "border-top: <+++>;\<++>", \'borb' : "border-bottom: <+++>;\<++>", \'borl' : "border-left: <+++>;\<++>", \'borr' : "border-right: <+++>;\<++>", \ \';abs' : "position: absolute;\<++>", \';rel' : "position: relative;\<++>", \';fix' : "position: fixed;\<++>", \ \';block' : "display: block;\<++>", \';inl' : "display: inline;\<++>", \';inb' : "display: inline-block;\<++>", \';flex' : "display: flex;\<++>", \';inf' : "display: inline-flex;\<++>", \ \} let g:quicktex_less = g:quicktex_css " Latex Normal {{{3 let g:quicktex_tex = { \' ' : "\/<+.*+>\\"_c/+>/e\", \';b' : "\\textbf{<+++>} <++>", \';e' : "\\emph{<+++>} <++>", \'prf' : "\\begin{proof}\<+++>\\\end{proof}", \';m' : "$<+++>$ <++>", \';M' : "\\[ <+++> \\] <++>", \';ma' : "$a$ ", \';mb' : "$b$ ", \';mc' : "$c$ ", \';md' : "$d$ ", \';me' : "$e$ ", \';mf' : "$f$ ", \';mg' : "$g$ ", \';mh' : "$h$ ", \';mi' : "$i$ ", \';mj' : "$j$ ", \';mk' : "$k$ ", \';ml' : "$l$ ", \';mm' : "$m$ ", \';mn' : "$n$ ", \';mo' : "$o$ ", \';mp' : "$p$ ", \';mq' : "$q$ ", \';mr' : "$r$ ", \';ms' : "$s$ ", \';mt' : "$t$ ", \';mu' : "$u$ ", \';mv' : "$v$ ", \';mw' : "$w$ ", \';mx' : "$x$ ", \';my' : "$y$ ", \';mz' : "$z$ ", \';mA' : "$A$ ", \';mB' : "$B$ ", \';mC' : "$C$ ", \';mD' : "$D$ ", \';mE' : "$E$ ", \';mF' : "$F$ ", \';mG' : "$G$ ", \';mH' : "$H$ ", \';mI' : "$I$ ", \';mJ' : "$J$ ", \';mK' : "$K$ ", \';mL' : "$L$ ", \';mM' : "$M$ ", \';mN' : "$N$ ", \';mO' : "$O$ ", \';mP' : "$P$ ", \';mQ' : "$Q$ ", \';mR' : "$R$ ", \';mS' : "$S$ ", \';mT' : "$T$ ", \';mU' : "$U$ ", \';mV' : "$V$ ", \';mW' : "$W$ ", \';mX' : "$X$ ", \';mY' : "$Y$ ", \';mZ' : "$Z$ ", \} " Latex Maths {{{3 let g:quicktex_math = { \' ' : "\/<+.*+>\\"_c/+>/e\", \';b' : "\\mathbf{<+++>} <++>", \';B' : "\\mathbb{<+++>} <++>", \'fr' : '\mathcal{R} ', \'eq' : '= ', \'set' : '\{ <+++> \} <++>', \'frac' : '\frac{<+++>}{<++>} <++>', \'in' : '\in ', \'bn' : '\mathbb{N} ', \} " Markdown {{{3 let g:quicktex_markdown = { \' ' : "\/<+.*+>\\"_c/+>/e\", \';b' : "**<+++>** <++>", \';i' : "*<+++>* <++>", \';a' : "[<+++>](<+url+>) <++>", \} let g:quicktex_pandoc = g:quicktex_markdown "}}} "}}} " Functions {{{1 function! NextMark() execute "normal! /(<.>)\zvda(" execute "startinsert" endfunction function! NewHtml() read ~/Templates/html normal! ggdd setlocal filetype=html "call NextMark() endfunction function! NewLatex() read ~/Templates/latex normal! ggdd setlocal filetype=tex endfunction " Mappings {{{1 " Move lines up/down using arrow keys nnoremap ddp nnoremap ddkP nnoremap xp nnoremap xhP " Activate spelling nnoremap :set spell! " Disable Scroll wheel noremap noremap " Make Ctrl C and Ctrl V work on system buffer " 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]."`]" " " Set :w!! to save with sudo cnoremap w!! w !sudo tee % "Run current line as command nnoremap q !!$SHELL " Do Shebang line inoremap :sil exe ".!which " s/^/#!/ filetype detectYpDi " 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 " Set double space in insert mode to go to next mark and enter insert mode "inoremap :call NextMark() " Abreviations {{{1 iabbrev @@ jonathan@fellowshipproductions.co.uk iabbrev @@@ jonathan@lunarweb.co.uk " Start Screen Settings {{{1 fun! Start() " Don't run if: we have commandline arguments, we don't have an empty " buffer, if we've not invoked as vim or gvim, or if we'e start in insert mode if argc() || line2byte('$') != -1 || v:progname !~? '^[-gmnq]\=vim\=x\=\%[\.exe]$' || &insertmode return endif " Start a new buffer ... enew " ... and set some options for it setlocal \ bufhidden=wipe \ buftype=nofile \ nobuflisted \ nocursorcolumn \ nocursorline \ nolist \ nonumber \ noswapfile \ norelativenumber " Now we can just write to the buffer, whatever you want. call append('$', "") for line in split(system('fortune -a | cowsay'), '\n') call append('$', ' ' . l:line) endfor " No modifications to this buffer setlocal nomodifiable nomodified " When we go to insert mode start a new buffer, and start insert nnoremap e :enew nnoremap i :enew startinsert nnoremap o :enew startinsert endfun " Run after "doing all the startup stuff" " autocmd VimEnter * call Start() " 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 autocmd FileType html,xhtml,css,less,javascript,php EmmetInstall 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! " 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_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 ""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