Last active
March 11, 2024 06:23
-
-
Save sampollard/772c5cfb660862ea160f10ed1eb77e5a to your computer and use it in GitHub Desktop.
My Vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ vimrc | |
| " Install some packages I like | |
| " mkdir -p ~/.vim/pack/bundle/start | |
| " cd ~/.vim/pack/bundle/start | |
| " git clone https://tpope.io/vim/surround.git | |
| " vim -u NONE -c "helptags surround/doc" -c q | |
| " git clone https://tpope.io/vim/commentary.git | |
| " vim -u NONE -c "helptags commentary/doc" -c q | |
| " git clone https://github.com/atelierbram/vim-colors_atelier-schemes.git | |
| " git clone https://github.com/trefis/coquille.git | |
| " echo "" > coquille/ftplugin/coq.vim # I just want syntax highlighting | |
| " git clone https://github.com/whonore/Coqtail.git | |
| " vim +helptags\ ~/.vim/pack/bundle/start/Coqtail/doc +q | |
| " http://www.drchip.org/astronaut/vim/index.html#LATEXPKGS | |
| " cd - | |
| " echo You also want to open http://www.drchip.org/astronaut/vim/index.html#LATEXPKGS | |
| " echo and download amsmath and lstlisting (wget seems to be rejected by Dr. Chip). | |
| " echo -e "then run\n vim '+so %' +qall amsmath.vba.gz\n | |
| " echo vim '+so %' +qall lstlisting.vba.gz\n | |
| " vim +helptags +qall | |
| " Basic stuff to bring the editor 3 decades forward | |
| set nocompatible | |
| filetype plugin on | |
| set noerrorbells visualbell t_vb= | |
| autocmd GUIEnter * set visualbell t_vb= | |
| set ruler | |
| set showcmd | |
| set backspace=indent,eol,start | |
| syntax enable | |
| set tags+=tags;~ | |
| set mouse=a " Allow scrolling with mouse | |
| """ Display and Colors | |
| colorscheme Atelier_LakesideLight | |
| hi clear Normal | |
| set termguicolors | |
| hi Normal ctermbg=NONE guibg=NONE | |
| highlight TabLine guifg=Gray | |
| highlight TabLineFill guifg=Blue | |
| " Setting italics must be done after all other theme options | |
| highlight Visual term=reverse gui=reverse cterm=reverse ctermbg=Green | |
| highlight Comment cterm=italic | |
| " Set terminal characters to send for italics mode | |
| let &t_ZH="\e[3m" | |
| let &t_ZR="\e[23m" | |
| " I like tabs to be tabs and 4 characters wide with some exceptions. | |
| set smarttab | |
| set tabstop=4 | |
| set shiftwidth=4 | |
| set listchars=tab:>-,trail:· | |
| set ff=unix | |
| """ Language Specific stuff | |
| autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab | |
| autocmd FileType make set tabstop=8|set shiftwidth=8|set noexpandtab | |
| autocmd FileType haskell set tabstop=8|set shiftwidth=2|set expandtab | |
| autocmd BufEnter *.txx :setlocal filetype=cpp | |
| autocmd BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.md set ft=markdown | |
| autocmd FileType markdown set textwidth=72|set spell | |
| autocmd FileType latex set textwidth=72|set spell|syntax spell toplevel | |
| au filetype tex syntax region texZone start='\\begin{lstlisting}' end='\\end{lstlisting}' | |
| au FileType coq set textwidth=72|set shiftwidth=2 | |
| """ LaTeX | |
| autocmd FileType latex set textwidth=72|setlocal spell|syntax spell toplevel | |
| au filetype tex syntax region texZone start='\\begin{lstlisting}' end='\\end{lstlisting}' | |
| " Vimtex: use Ctrl-enter to forward search, ctrl-click to backward search | |
| function! Synctex() | |
| let execstr = "silent !okular --unique %:p:r.pdf\\#src:".line(".")."%:p &" | |
| exec execstr | |
| endfunction | |
| map <C-enter> :call Synctex()<cr> | |
| """ GUI | |
| if has('gui_running') | |
| set guifont=Menlo\ Regular:h14 | |
| set background=light | |
| hi Normal guibg='Light Cyan' | |
| set guioptions-=T | |
| "colorscheme Atelier_LakesideDark | |
| highlight Comment gui=italic | |
| endif | |
| """ Cool things I've come across: | |
| " Delete trailing whitespace - by default across the whole file | |
| command! -range=% DTW <line1>,<line2>s/\s\+$//e | |
| " Switch the ordering of a comma-separated list of author names from | |
| " 'A. Turing and A. Church' into 'Turing, A. and Church, A.' | |
| command! -range=% Lnfn <line1>,<line2>s/\(\%([^, ]\+ \)\+\)\([^, ]\+\),\|$/\2, \1and/e | <line1>,<line2>s/\_.*\zsand//e | |
| " Round to a given number of digits | |
| command! -nargs=1 -range Round <line1>,<line2>s/\d\+\.\d\+/\=printf('%.<args>f',str2float(submatch(0)))/g | |
| command! -range Int <line1>,<line2>s/\d\+\.\d\+/\=printf('%.0f',str2float(submatch(0)))/g | |
| " Replace dash-style lists with numbered lists in markdown | |
| " let t=[] | %s/^-/\=len(add(t,1)).'.'/gc | |
| " In visual mode, <leader>c will turn into a code block | |
| let b:surround_{char2nr('c')} = "```\r```" | |
| """ Leader commands | |
| " Try out my mini 'spacemacs' | |
| map <SPACE> <leader> | |
| " But if I still want to use space to move, it goes at 1/2 speed :-) | |
| nnoremap <leader><SPACE> l | |
| noremap <leader>1 1gt | |
| noremap <leader>2 2gt | |
| noremap <leader>3 3gt | |
| noremap <leader>4 4gt | |
| noremap <leader>5 5gt | |
| noremap <leader>6 6gt | |
| noremap <leader>7 7gt | |
| noremap <leader>8 8gt | |
| noremap <leader>9 9gt | |
| noremap <leader>0 :tablast<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment