Created
October 21, 2017 13:02
-
-
Save jackbaty/35b279d5074c05357ce0bbe36b368eb1 to your computer and use it in GitHub Desktop.
.vimrc as of 2017-10-21
This file contains 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
" My current .vimrc file | |
" Jack Baty | |
" [email protected] | |
" Environment | |
set nocompatible " We don't want vi compatibility. | |
filetype off " still needed? | |
set shell=/bin/bash\ -i | |
" PLUGINS | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
" Install automatically | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
call plug#begin('~/.vim/plugged') | |
" Make sure to use single quotes | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-rhubarb' | |
Plug 'shumphrey/fugitive-gitlab.vim' | |
Plug 'whatyouhide/vim-gotham' | |
Plug 'Lokaltog/vim-easymotion' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-markdown' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'vimwiki/vimwiki', { 'branch': 'dev' } | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-vinegar' | |
Plug 'itspriddle/vim-marked' | |
Plug 'vim-pandoc/vim-pandoc' | |
Plug 'vim-pandoc/vim-pandoc-syntax' | |
Plug 'dhruvasagar/vim-table-mode' | |
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'altercation/vim-colors-solarized' | |
Plug 'junegunn/goyo.vim' | |
" Initialize plugin system | |
call plug#end() | |
" GENERAL BEHAVIOR AND UI | |
filetype plugin indent on " required | |
set clipboard=unnamed | |
syntax on | |
set background=dark | |
colorscheme solarized | |
set guifont=Nitti\ Light:h14 | |
"set guifont=Cousine:h14 | |
" switch to current file's directory on new buffer | |
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif | |
set modelines=0 " I don't use modelines | |
set encoding=utf-8 | |
set foldlevelstart=20 " not a fan of automatic folding | |
set scrolloff=4 " keep at least 3 lines visible around cursor | |
set nonu " Line numbers off | |
set autoindent " indent stays same as last line | |
set showmode " so we know which mode we're in | |
set foldcolumn=2 " Don't jam things up on the left so much | |
set cursorline " highlight current line | |
if has('cmdline_info') | |
set ruler " show the ruler | |
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " better ruler | |
set showcmd " show partial commands in status line and | |
" selected characters/lines in visual mode | |
endif | |
set hidden " don't ask me to save all the time | |
set wildmenu " much better filename completion | |
set wildmode=list:longest | |
set visualbell " don't beep | |
set novisualbell " don't blink | |
set noerrorbells " no noise please | |
set ttyfast " better scrolling | |
set backspace=indent,eol,start | |
set laststatus=2 " always show status line. | |
set ignorecase " case-insensitive search... | |
set smartcase " ...unless there's some uppercase present | |
set gdefault " default to /g flag during substitutions | |
set incsearch " incremental search as you type | |
set showmatch " indicate matching brackets and parens | |
set hlsearch " highlight search hits | |
set scrolljump=5 " lines to scroll when cursor leaves screen | |
set timeoutlen=250 " Time to wait after ESC (default causes a delay) | |
" FORMATTING | |
set ts=4 " Tabs are 4 spaces | |
set textwidth=79 " wrap width | |
set wrap " wrap on (since I rarely write code anyway) | |
set linebreak " wrap at boundaries | |
set wm=2 " leave a little margin when wrapping | |
set softtabstop=4 " Backspace over everything in insert mo | |
set shiftwidth=4 " Tabs under smart indent | |
set expandtab " Spaces please | |
set formatoptions=tcq " Line formatting options: | |
" t Auto-wrap text using textwidth | |
" c Auto-wrap comments using textwidth, inserting the | |
" current comment leader automatically. | |
" q Allow formatting of comments with "gq". | |
" w Trailing white space indicates a paragraph | |
" continues in the next line. Toggled for emails / | |
" prose only | |
set smarttab " better tab behavior | |
set confirm " easier confirmation | |
set list listchars=tab:\ \ ,trail:· " Display tabs and trailing spaces visually | |
set backupdir=~/.bak,.,~ " Keep all backups in ~/.bak | |
set directory=~/.bak,.,~ | |
set grepprg=grep\ -nH\ $* | |
let g:tex_flavor='latex' | |
" PLUGIN CONFIG | |
" VimWiki | |
let g:vimwiki_list = [{'path': '~/Dropbox/@Archive/@Notes/wiki','syntax': 'markdown', 'ext': '.md'}] | |
let g:vimwiki_folding='expr' | |
let g:vimwiki_global_ext=0 | |
" Turn on case sensitive feature | |
let g:EasyMotion_smartcase = 1 | |
" MAPPINGS AND SHORTCUTS ------------------------------------------------- | |
let mapleader = "\<Space>" " Spacemacs had the right idea | |
let maplocalleader="," | |
inoremap jk <Esc> " For when there's not a real Escape key | |
nnoremap Q gqip " hard wrap | |
" Yank text to the OS X clipboard | |
noremap <leader>y "*y | |
noremap <leader>yy "*Y | |
" Preserve indentation while pasting text from the OS X clipboard | |
noremap <leader>p :set paste<CR>:put *<CR>:set nopaste<CR> | |
" Repeat visual command | |
vnoremap . :norm.<CR> | |
map <C-n> :NERDTreeToggle<CR> | |
" Spelling | |
nnoremap <leader>f 1z= | |
nnoremap <leader>s :set spell! | |
" change to current directory | |
cmap cd. lcd %:p:h | |
" easier window navigation | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Sane line movement when wrapped | |
nmap j gj | |
nmap k gk | |
" FZF (replaces Ctrl-P, FuzzyFinder and Command-T) | |
" Configured to use `ag` so .gitignore, etc. are used. | |
" Also uses path of current .git repo root instead of cwd | |
" Stolen from some kind soul on the internet whom I've forgotten | |
set rtp+=/usr/local/opt/fzf | |
set rtp+=~/.fzf | |
fun! s:fzf_root() | |
let path = finddir(".git", expand("%:p:h").";") | |
return fnamemodify(substitute(path, ".git", "", ""), ":p:h") | |
endfun | |
" FZF mappings are suspicially similar to Spacemacs | |
nnoremap <silent> <Leader>ff :exe 'Files ' . <SID>fzf_root()<CR> | |
nnoremap <silent> <Leader>fc :Colors<CR> | |
nnoremap <silent> <Leader>fh :History<CR> | |
nnoremap <silent> <Leader>bb :Buffers<CR> | |
nnoremap <silent> <Leader>; :Commands<CR> | |
nnoremap <silent> <Leader>h :Helptags<CR> | |
nnoremap <silent> <Leader>ll :Lines<CR> | |
nnoremap <silent> <Leader>lb :BLines<CR> | |
" Tell ack.vim to use ag (the Silver Searcher) instead | |
let g:ackprg = 'ag --vimgrep' | |
"clear highlighted search | |
nmap <silent> <leader>/ :nohlsearch<CR> | |
" Bi-directional find motion with one key | |
" `s{char}{label}` | |
nmap s <Plug>(easymotion-s) | |
" or | |
" `s{char}{char}{label}` | |
" Use the tab key to toggle folds | |
nnoremap <tab> za | |
vnoremap <tab> zf | |
" Git status | |
nmap \g :Gstatus<CR> | |
" JK motions: Line motions | |
map <Leader>j <Plug>(easymotion-j) | |
map <Leader>k <Plug>(easymotion-k) | |
" Math | |
vmap <expr> ++ VMATH_YankAndAnalyse() | |
nmap ++ vip++ | |
au BufNewFile,BufRead *todo.txt set filetype=todo | |
au BufNewFile,BufRead *eml.txt set filetype=mail | |
" Use format=flowed for mail messages | |
augroup mail_trailing_whitespace " { | |
autocmd! | |
autocmd FileType mail setlocal formatoptions+=w | |
augroup END " } | |
" I don't really undertand these so may come back later | |
"au BufWinLeave *.* silent! mkview | |
"au BufWinEnter *.* silent! loadview | |
"pandoc settings | |
let g:pandoc#syntax#conceal#use = 0 | |
let g:pandoc#modules#disabled = ['spell'] | |
let g:pandoc#folding#fdc = 3 | |
let g:pandoc#command#templates_file = "/Users/jbaty/.pandoc/vim_pandoc_templates" | |
" make table both pandoc and github lovable | |
let g:table_mode_separator = '|' | |
let g:table_mode_corner = '+' | |
let g:table_mode_corner_corner = '+' | |
let g:table_mode_header_fillchar = "=" | |
"let g:fugitive_gitlab_domains = ['https://gitlab.fusionary.com'] | |
" Softwrap the document | |
command! -range=% SoftWrap | |
\ <line2>put _ | | |
\ <line1>,<line2>g/.\+/ .;-/^$/ join |normal $x | |
" Prose is nice thanks to Ian Langworth (https://statico.github.io/vim3.html) | |
function! ProseMode() | |
call goyo#execute(0, []) | |
set spell noci nosi noai nolist noshowmode noshowcmd | |
set complete+=s | |
set bg=light | |
if !has('gui_running') | |
let g:solarized_termcolors=256 | |
endif | |
colors solarized | |
endfunction | |
command! ProseMode call ProseMode() | |
nmap \p :ProseMode<CR> | |
" Open current file in BBEdit | |
nnoremap ,bb :!/usr/local/bin/bbedit "%" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🖖