" _
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___|
let mapleader =" "
" Load Pathogen for plugins:
execute pathogen#infect()
execute pathogen#helptags()
" Some basics:
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set number
set relativenumber
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow
set splitright
" Shortcutting split navigation, saving a keypress:
map h
map j
map k
map l
" Open file as suckless sent presentation
map s :!sent% 2>/dev/null &
" View an image for a suckless sent presentation:
map v $F@ly$:!feh --scale-down --auto-zoom --image-bg black " &
" Open my bibliography file in split
map :vsp~/Documents/LaTeX/uni.bib
map b :vsp~/Documents/LaTeX/uni.bib
" Open the selected text in a split (i.e. should be a file).
map o "oyaW:sp o
xnoremap o "oy:sp o
vnoremap o "oy:sp o
" Replace all is aliased to S.
nnoremap S :%s//g
" Open corresponding.pdf
map p :!opout %
" Compile document
map c :!compiler %
"For saving view folds:
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview
" Interpret .md files, etc. as .markdown
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
" Make calcurse notes markdown compatible:
autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
" Readmes autowrap text:
autocmd BufRead,BufNewFile *README.md set tw=79
" Get line, word and character counts with F3:
map :!wc %
" Spell-check set to F6:
map :setlocal spell! spelllang=en_us,es
" Toggle DeadKeys set (for accent marks):
so ~/.vim/luke/deadkeys.vim
nm d :call ToggleDeadKeys()
imap d :call ToggleDeadKeys()a
" Source my IPA shorcuts:
so ~/.vim/luke/ipa.vim
nm i :call ToggleIPA()
imap i :call ToggleIPA()a
" Use urlview to choose and open a url:
:noremap u :wsilent !urlview
:noremap ,, :wsilent !urlview
" Copy selected text to system clipboard (requires gvim installed):
vnoremap "*Y :let @+=@*
map "+P
" Goyo plugin makes text more readable when writing prose:
map :Goyo
map f :Goyo \| set linebreak
inoremap :Goyoa
" Toggle Prose Mode with F8:
so ~/.vim/luke/prose.vim
nm :call ToggleProse()
" Enable Goyo by default for mutt writting
" Goyo's width will be the line limit in mutt.
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo
" Enable autocompletion:
set wildmode=longest,list,full
set wildmenu
" Automatically deletes all tralling whitespace on save.
autocmd BufWritePre * %s/\s\+$//e
" When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost ~/.scripts/folders,~/.scripts/configs !bash ~/.scripts/shortcuts.sh
" Runs a script that cleans out tex build files whenever I close out of a .tex file.
autocmd VimLeave *.tex !texclear
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" C-T for new tab
nnoremap :tabnew
" Navigating with guides
inoremap /<++>"_c4l
vnoremap /<++>"_c4l
map /<++>"_c4l
" For normal mode when in terminals (in X I have caps mapped to esc, this replaces it when I don't have X)
inoremap jw
inoremap wj
"____ _ _
"/ ___| _ __ (_)_ __ _ __ ___| |_ ___
"\___ \| '_ \| | '_ \| '_ \ / _ \ __/ __|
"___) | | | | | |_) | |_) | __/ |_\__ \
"|____/|_| |_|_| .__/| .__/ \___|\__|___/
"|_| |_|
"""LATEX
" Word count:
autocmd FileType tex map :w !detex \| wc -w
autocmd FileType tex inoremap :w !detex \| wc -w
" Compile document using xelatex:
autocmd FileType tex inoremap :!xelatex%a
autocmd FileType tex nnoremap :!xelatex%
" Code snippets
autocmd FileType tex inoremap ,fr \begin{frame}\frametitle{}<++>\end{frame}<++>6kf}i
autocmd FileType tex inoremap ,fi \begin{fitch}\end{fitch}<++>3kA
autocmd FileType tex inoremap ,exe \begin{exe}\ex\end{exe}<++>3kA
autocmd FileType tex inoremap ,em \emph{}<++>T{i
autocmd FileType tex inoremap ,bf \textbf{}<++>T{i
autocmd FileType tex vnoremap , ``>2la}?\\{a
autocmd FileType tex inoremap ,it \textit{}<++>T{i
autocmd FileType tex inoremap ,ct \textcite{}<++>T{i
autocmd FileType tex inoremap ,cp \parencite{}<++>T{i
autocmd FileType tex inoremap ,glos {\gll<++>\\<++>\\\trans{``<++>''}}2k2bcw
autocmd FileType tex inoremap ,x \begin{xlist}\ex\end{xlist}kA
autocmd FileType tex inoremap ,ol \begin{enumerate}\end{enumerate}<++>3kA\item
autocmd FileType tex inoremap ,ul \begin{itemize}\end{itemize}<++>3kA\item
autocmd FileType tex inoremap ,li \item
autocmd FileType tex inoremap ,ref \ref{}<++>T{i
autocmd FileType tex inoremap ,tab \begin{tabular}<++>\end{tabular}<++>4kA{}i
autocmd FileType tex inoremap ,ot \begin{tableau}\inp{<++>}\const{<++>}<++><++>\end{tableau}<++>5kA{}i
autocmd FileType tex inoremap ,can \cand{}<++>T{i
autocmd FileType tex inoremap ,con \const{}<++>T{i
autocmd FileType tex inoremap ,v \vio{}<++>T{i
autocmd FileType tex inoremap ,a \href{}{<++>}<++>2T{i
autocmd FileType tex inoremap ,sc \textsc{}<++>T{i
autocmd FileType tex inoremap ,chap \chapter{}<++>2kf}i
autocmd FileType tex inoremap ,sec \section{}<++>2kf}i
autocmd FileType tex inoremap ,ssec \subsection{}<++>2kf}i
autocmd FileType tex inoremap ,sssec \subsubsection{}<++>2kf}i
autocmd FileType tex inoremap ,st F{i*f}i
autocmd FileType tex inoremap ,beg \begin{DELRN}<++>\end{DELRN}<++>4k0fR:MultipleCursorsFindDELRNc
autocmd FileType tex inoremap ,up /usepackageo\usepackage{}i
autocmd FileType tex nnoremap ,up /usepackageo\usepackage{}i
autocmd FileType tex inoremap ,tt \texttt{}<++>T{i
autocmd FileType tex inoremap ,bt {\blindtext}
autocmd FileType tex inoremap ,nu $\varnothing$
autocmd FileType tex inoremap ,col \begin{columns}[T]\begin{column}{.5\textwidth}\end{column}\begin{column}{.5\textwidth}<++>\end{column}\end{columns}5kA
autocmd FileType tex inoremap ,rn (\ref{})<++>F}i
"""PHP/HTML
autocmd FileType php,html inoremap ,b <++>FbT>i
autocmd FileType php,html inoremap ,it <++>FeT>i
autocmd FileType php,html inoremap ,1 <++>2kf<++>2kf<++>2kf
<++>02kf>a
autocmd FileType php,html inoremap ,a href=""><++><++>14hi
autocmd FileType php,html inoremap ,e target="_blank"href=""><++><++>14hi
autocmd FileType php,html inoremap ,ul <++>03kfoF>a
autocmd FileType php,html inoremap ,ol
<++>03kf<++>Fcf"a
autocmd FileType php,html inoremap ,td | <++>Fdcit
autocmd FileType php,html inoremap ,tr
<++>kf<++>Fhcit
autocmd FileType php,html inoremap ,tab O
autocmd FileType php,html inoremap ,gr F>a
autocmd FileType php,html inoremap ,rd F>a
autocmd FileType php,html inoremap ,yl F>a
autocmd FileType php,html inoremap ,dt <++><++>2kcit
autocmd FileType php,html inoremap ,dl
<++>3kcc
autocmd FileType php,html inoremap & &
""".bib
autocmd FileType bib inoremap ,a @article{author="<++>",year="<++>",title="<++>",journal="<++>",volume="<++>",pages="<++>",}<++>8kA,i
autocmd FileType bib inoremap ,b @book{author="<++>",year="<++>",title="<++>",publisher="<++>",}<++>6kA,i
autocmd FileType bib inoremap ,c @incollection{author="<++>",title="<++>",booktitle="<++>",editor="<++>",year="<++>",publisher="<++>",}<++>8kA,i
"MARKDOWN
autocmd Filetype markdown,rmd map w yiWi[Ea](pa)
autocmd Filetype markdown,rmd inoremap ,n ---
autocmd Filetype markdown,rmd inoremap ,b ****<++>F*hi
autocmd Filetype markdown,rmd inoremap ,s ~~~~<++>F~hi
autocmd Filetype markdown,rmd inoremap ,e **<++>F*i
autocmd Filetype markdown,rmd inoremap ,h ====<++>F=hi
autocmd Filetype markdown,rmd inoremap ,i ![](<++>)<++>F[a
autocmd Filetype markdown,rmd inoremap ,a [](<++>)<++>F[a
autocmd Filetype markdown,rmd inoremap ,1 #<++>kA
autocmd Filetype markdown,rmd inoremap ,2 ##<++>kA
autocmd Filetype markdown,rmd inoremap ,3 ###<++>kA
autocmd Filetype markdown,rmd inoremap ,l --------
autocmd Filetype rmd inoremap ,r ```{r}```2kO
autocmd Filetype rmd inoremap ,p ```{python}```2kO
autocmd Filetype rmd inoremap ,c ``````2kO
""".xml
autocmd FileType xml inoremap ,e - <++>isPermaLink="false"><++>:put=strftime('%a, %d %b %Y %H:%M:%S %z')kJA<++>]]>
?cit
autocmd FileType xml inoremap ,a <++><++>F"ci"
vmap ++ VMATH_YankAndAnalyse()
nmap ++ vip++
vnoremap K xkP`[V`]
vnoremap J xp`[V`]
vnoremap L >gv
vnoremap H yi[:e "