Created
January 26, 2017 15:24
-
-
Save MLKrisJohnson/172bad45c54f8678a12a1b7a21d6a1db to your computer and use it in GitHub Desktop.
My .vimrc and .gvimrc
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
if has('win32') || has('win64') | |
set guifont=Consolas:h12:cANSI | |
command! BigFont set guifont=Consolas:h15:cANSI | |
command! SmallFont set guifont=Consolas:h12:cANSI | |
command! TinyFont set guifont=Consolas:h9:cANSI | |
else | |
set guifont=Source\ Code\ Pro\ Light:h15 | |
command! BigFont set guifont=Source\ Code\ Pro\ Light:h18 | |
command! SmallFont set guifont=Source\ Code\ Pro\ Light:h15 | |
command! TinyFont set guifont=Source\ Code\ Pro\ Light:h10 | |
endif | |
" Remove toolbar | |
set guioptions-=T | |
" Remove scrollbars | |
set guioptions-=r | |
set guioptions-=R | |
set guioptions-=l | |
set guioptions-=L | |
" Disable GUI tabs | |
set guioptions-=e | |
set linespace=1 |
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
" vim: set ts=8 sw=2 tw=78 et : | |
set nocompatible | |
" Tip: Use "zR" to open all folds, if the below is folded | |
" and you can't remember how to unfold things. | |
" Global variables {{{1 | |
" | |
let g:kj_foldcolumn = 4 | |
let g:kj_quickfix_is_open = 0 | |
" Options {{{1 | |
set autochdir | |
set autoread | |
set backspace=indent,eol,start | |
set backup | |
set complete-=i | |
set cursorline | |
set display+=lastline | |
set expandtab | |
set history=50 | |
set ignorecase | |
set incsearch | |
set laststatus=2 | |
set number | |
set ruler | |
set shiftround | |
set shiftwidth=4 | |
set showcmd | |
set showmatch | |
set smartcase | |
set smarttab | |
try | |
let &softtabstop = -1 " use the value of 'shiftwidth' implicitly | |
catch /^Vim:\(\a+\):E487:/ " 'Argument must be positive' | |
let &softtabstop = &shiftwidth " use the value of 'shiftwidth' directly | |
endtry | |
set tags=tags; | |
set undofile | |
set visualbell | |
set wildcharm=<C-z> | |
set wildmenu | |
set wildmode=longest:full,full | |
if has('win32') || has('win64') | |
let b:is_windows = 1 | |
else | |
let b:is_windows = 0 | |
endif | |
if b:is_windows | |
set backupdir=~/AppData/Local/Temp/vimbak//,~/AppData/Local/Temp//,$TEMP | |
set directory=~/AppData/Local/Temp/vimswp//,~/AppData/Local/Temp//,$TEMP | |
if has('persistent_undo') | |
set undodir=~/AppData/Local/Temp/vimundo//,~/AppData/Local/Temp//,$TEMP | |
endif | |
else | |
set backupdir=~/.vimbak//,$TMPDIR,/tmp// | |
set directory=~/.vimswp//,$TMPDIR,/tmp// | |
if has('persistent_undo') | |
set undodir=~/.vimundo//,$TMPDIR,/tmp// | |
endif | |
endif | |
if !&scrolloff | |
set scrolloff=1 | |
endif | |
if !&sidescrolloff | |
set sidescrolloff=2 | |
endif | |
if &encoding ==# 'latin1' && has('gui_running') | |
set encoding=utf-8 | |
endif | |
if &listchars ==# 'eol:$' | |
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ | |
endif | |
if v:version > 703 || v:version == 703 && has("patch541") | |
set formatoptions+=j " Delete comment character when joining commented lines | |
endif | |
if has('path_extra') | |
setglobal tags-=./tags tags-=./tags; tags^=./tags; | |
endif | |
" Favor bash over zsh or fish | |
if &shell =~# '\vzsh$|fish$' | |
set shell=/bin/bash | |
endif | |
if &history < 1000 | |
set history=1000 | |
endif | |
if &tabpagemax < 50 | |
set tabpagemax=50 | |
endif | |
if !empty(&viminfo) | |
set viminfo^=! | |
endif | |
set sessionoptions-=options | |
if has('mouse') | |
set mouse=a | |
endif | |
" Allow color schemes to do bright colors without forcing bold. | |
if &t_Co == 8 && $TERM !~# '^linux\|^Eterm' | |
set t_Co=16 | |
endif | |
" Load matchit.vim, but only if the user hasn't installed a newer version. | |
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' | |
runtime! macros/matchit.vim | |
endif | |
if &t_Co > 2 || has("gui_running") | |
try | |
let g:zenburn_High_Contrast = 1 | |
let g:zenburn_old_Visual = 1 | |
let g:zenburn_alternate_Error = 1 | |
colorscheme zenburn | |
catch | |
" Fall back to a built-in color scheme if Zenburn is not available | |
"colorscheme desert | |
"colorscheme darkblue | |
"colorscheme evening | |
"colorscheme industry | |
"colorscheme koehler | |
colorscheme murphy | |
"colorscheme pablo | |
"colorscheme torte | |
endtry | |
syntax on | |
set hlsearch | |
endif | |
if has('gui_running') && (&lines < 40 || &columns < 140) | |
" If OS gave us a small window, make it bigger. | |
set lines=40 columns=140 | |
endif | |
" Key mappings {{{1 | |
let mapleader = '\' | |
let maplocalleader = ',' | |
" Normal-mode key mappings {{{2 | |
" Use Space to scroll down a page, Backspace to scroll up a page. | |
nnoremap <Space> <PageDown> | |
nnoremap <BS> <PageUp> | |
" Insert a space at current position. | |
nnoremap <Leader><Space> i<Space><Esc> | |
" Repeat editing commands on subsequent lines. | |
nnoremap <Leader>. mx.g`xj | |
nnoremap <Leader>, j^. | |
nnoremap <Leader>/ j$. | |
" Reindent the whole file. | |
nnoremap <Leader>= :%normal ==<CR> | |
" Format current paragraph. | |
nnoremap <Leader>p gqap | |
" Remove trailing whitespace. | |
nnoremap <silent> <Leader>$ :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> | |
" Toggle wrap setting. | |
nnoremap <Leader>r :setlocal wrap!<CR> | |
" Quickfix shortcuts | |
nnoremap <Leader>' :cnext<CR> | |
nnoremap <Leader>; :cprevious<CR> | |
nnoremap <Leader>q :call <SID>KJQuickfixToggle()<CR> | |
" Fold shortcuts | |
nnoremap <Leader>zi :execute 'setlocal foldcolumn=' . g:kj_foldcolumn . ' foldmethod=indent'<CR> | |
nnoremap <Leader>zs :execute 'setlocal foldcolumn=' . g:kj_foldcolumn . ' foldmethod=syntax'<CR> | |
nnoremap <Leader>zm :execute 'setlocal foldcolumn=' . g:kj_foldcolumn . ' foldmethod=manual'<CR> | |
nnoremap <Leader>zk :execute 'setlocal foldcolumn=' . g:kj_foldcolumn . ' foldmethod=marker'<CR> | |
nnoremap <Leader>zf :call <SID>KJFoldColumnToggle()<CR> | |
" shiftwidth shortcuts | |
nnoremap <Leader>2 :setlocal shiftwidth=2<CR> | |
nnoremap <Leader>3 :setlocal shiftwidth=3<CR> | |
nnoremap <Leader>4 :setlocal shiftwidth=4<CR> | |
" Close all folds except at cursor location. | |
nnoremap <Leader>zz zMzv | |
if b:is_windows | |
nnoremap <Leader>V :source ~/_vimrc<CR> | |
else | |
nnoremap <Leader>V :source ~/.vimrc<CR> | |
endif | |
nnoremap <Leader>M :MRU<CR> | |
" Show full path to file | |
nnoremap <Leader>P :echo expand('%:p')<CR> | |
nnoremap <Leader>[ <C-o> | |
nnoremap <Leader>] <C-i> | |
nnoremap <Leader>- <C-^> | |
" Window shortcuts | |
nnoremap <Leader>w <C-w>w | |
nnoremap <Leader>o <C-w>o | |
nnoremap <Leader><Left> <C-w><Left> | |
nnoremap <Leader><Down> <C-w><Down> | |
nnoremap <Leader><Right> <C-w><Right> | |
nnoremap <Leader><Up> <C-w><Up> | |
nnoremap <Leader>H <C-w>H | |
nnoremap <Leader>J <C-w>J | |
nnoremap <Leader>K <C-w>K | |
nnoremap <Leader>L <C-w>L | |
nnoremap <Leader>{ a{<CR><C-o>mx<CR>}<C-o>`x | |
" Open alternate file in vertical split | |
nnoremap <Leader># :execute "vertical rightbelow sbuffer " . bufnr('#')<CR> | |
if has('gui_running') | |
nnoremap <Leader>ew :drop ~/work/ | |
nnoremap <Leader>es :drop ~/scratch/ | |
nnoremap <Leader>ems :drop ~/ml2/src/ | |
nnoremap <Leader>emt :drop ~/ml2/test/ | |
nnoremap <Leader>eft :drop ~/.vim/ftplugin/ | |
nnoremap <Leader>en :drop ~/Dropbox/Notes/ | |
else | |
nnoremap <Leader>ew :edit ~/work/ | |
nnoremap <Leader>es :edit ~/scratch/ | |
nnoremap <Leader>ems :edit ~/ml2/src/ | |
nnoremap <Leader>emt :edit ~/ml2/test/ | |
nnoremap <Leader>eft :edit ~/.vim/ftplugin/ | |
nnoremap <Leader>en :edit ~/Dropbox/Notes/ | |
endif | |
if has('gui_running') | |
if b:is_windows | |
nnoremap <Leader>v :drop ~/_vimrc<CR> | |
else | |
nnoremap <Leader>v :drop ~/.vimrc<CR> | |
endif | |
nnoremap <Leader>s :drop ~/Dropbox/scratch.txt<CR> | |
else | |
if b:is_windows | |
nnoremap <Leader>v :edit ~/_vimrc<CR> | |
else | |
nnoremap <Leader>v :edit ~/.vimrc<CR> | |
endif | |
nnoremap <Leader>s :edit ~/Dropbox/scratch.txt<CR> | |
endif | |
if has("gui-macvim") | |
nnoremap <D-[> <C-o> | |
nnoremap <D-]> <C-i> | |
endif | |
" Show syntax group of item under cursor. | |
" Credit: <http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor> | |
nnoremap <Leader>S :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' | |
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" | |
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> | |
" Insert-mode key mappings {{{2 | |
inoremap jj <Esc> | |
inoremap <C-u> <C-g>u<C-u> | |
inoremap <C-w> <C-g>u<C-u> | |
inoremap ;; <Esc>A;<Esc> | |
inoremap ;;; <Esc>A;<CR> | |
" Terminal-mode key mappings (NeoVim) {{{2 | |
if has('nvim') | |
" Exit terminal mode | |
:tnoremap <Esc> <C-\><C-n> | |
endif | |
" Abbreviations {{{1 | |
iabbrev kj Kristopher Johnson | |
iabbrev @@ [email protected] | |
iabbrev mlem [email protected] | |
iabbrev ckj Copyright ©2017 Kristopher Johnson | |
iabbrev cml Copyright ©2017 Mobile Labs, LLC | |
cabbrev vh vertical botright help | |
cabbrev vr vertical resize | |
cabbrev man Man | |
" Plugins {{{1 | |
runtime! ftplugin/man.vim | |
" vim-plug <https://github.com/junegunn/vim-plug> | |
if b:is_windows | |
let b:vim_plug_directory='~/vimfiles/plugged' | |
else | |
let b:vim_plug_directory='~/.vim/plugged' | |
endif | |
if isdirectory(expand(b:vim_plug_directory)) | |
call plug#begin(b:vim_plug_directory) | |
Plug 'keith/swift.vim' | |
Plug 'rizzatti/dash.vim' | |
Plug 'git://github.com/rking/ag.vim.git' | |
Plug 'fatih/vim-go' | |
Plug 'https://github.com/WolfgangMehner/vim-support.git' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'https://github.com/yegappan/mru.git' | |
Plug 'Townk/vim-autoclose' | |
Plug 'MLKrisJohnson/vim-dclog' | |
Plug 'MLKrisJohnson/vim-trustlog' | |
call plug#end() | |
endif | |
" NERDCommenter Options {{{2 | |
" Add spaces after comment delimiters by default | |
let g:NERDSpaceDelims = 1 | |
" Allow commenting and inverting empty lines (useful when commenting a region) | |
let g:NERDCommentEmptyLines = 1 | |
" Enable trimming of trailing whitespace when uncommenting | |
let g:NERDTrimTrailingWhitespace = 1 | |
" Functions {{{! | |
" From <http://learnvimscriptthehardway.stevelosh.com/chapters/38.html> | |
function! s:KJQuickfixToggle() | |
if g:kj_quickfix_is_open | |
cclose | |
let g:kj_quickfix_is_open = 0 | |
execute g:kj_quickfix_return_to_window . "wincmd w" | |
else | |
let g:kj_quickfix_return_to_window = winnr() | |
copen | |
let g:kj_quickfix_is_open = 1 | |
endif | |
endfunction | |
" From <http://learnvimscriptthehardway.stevelosh.com/chapters/38.html> | |
function! s:KJFoldColumnToggle() | |
if &foldcolumn | |
setlocal foldcolumn=0 | |
else | |
execute 'setlocal foldcolumn=' . g:kj_foldcolumn | |
endif | |
endfunction | |
" Commands {{{1 | |
" :O FILENAME to open file or jump to it if it's already open. | |
command! -nargs=1 -complete=file O tab drop <args> | |
" Resize window to full screen size | |
command! Maximize set lines=999 columns=999 | |
" Print decimal number as hexadecimal | |
command! -nargs=1 D2x echo printf("%x", <args>) | |
" Insert MIT license | |
command! MitLicense read ~/dotfiles/share/mitlicense.txt | |
" Insert BSD license | |
command! BsdLicense read ~/dotfiles/share/bsdlicense.txt | |
" Highlight pattern with 'standout' style | |
command! -nargs=+ Highlight | |
\ highlight KJStandout term=standout cterm=standout gui=standout | | |
\ 2match KJStandout <args> | |
" Highlight pattern with reverse video | |
command! -nargs=+ Reverse | |
\ highlight KJReverse term=reverse cterm=reverse gui=reverse | | |
\ 2match KJReverse <args> | |
" Highlight pattern with 'underline' style | |
command! -nargs=+ Underline | |
\ highlight KJUnderline term=underline cterm=underline gui=underline | | |
\ 2match KJUnderline <args> | |
" Highlight pattern with 'undercurl' | |
command! -nargs=+ Undercurl | |
\ highlight KJUndercurl term=undercurl cterm=undercurl gui=undercurl | | |
\ 2match KJUndercurl <args> | |
" Turn off highlighting from Highlight, Reverse, Underline, and Undercurl | |
command! MatchOff match none | 2match none | 3match none | |
command! MessagesFileType setlocal filetype=messages | |
" Apply json_pp filter to the entire buffer. | |
" Also set shiftwidth to match json_pp's indentation. | |
command! JsonPP setlocal shiftwidth=3 | 1,$!json_pp | |
command! ToggleWrap setlocal wrap! | |
" Reopen file in DOS (CRLF) format | |
command! AsDos edit ++ff=dos | |
" Reopen file in Unix (lF) format | |
command! AsUnix edit ++ff=unix | |
if has('gui_running') | |
command! MLAirStreamConfig drop ~/AirStreamData/AirStream.config<CR> | |
command! MLServicesLog drop ~/AirStreamData/Logs/MobileLabs.DeviceConnect.Services.log<CR> | |
command! MLWebLog drop ~/AirStreamData/Logs/MobileLabs.AirStream.Web.log<CR> | |
command! MLErrorLog drop ~/AirStreamData/Logs/Error.log<CR> | |
command! MLFatalLog drop ~/AirStreamData/Logs/Fatal.log<CR> | |
command! MLBashConfig drop ~/Dropbox/bin/bashrc_MobileLabs.sh<CR> | |
else | |
command! MLAirStreamConfig edit ~/AirStreamData/AirStream.config<CR> | |
command! MLServicesLog edit ~/AirStreamData/Logs/MobileLabs.DeviceConnect.Services.log<CR> | |
command! MLWebLog edit ~/AirStreamData/Logs/MobileLabs.AirStream.Web.log<CR> | |
command! MLErrorLog edit ~/AirStreamData/Logs/Error.log<CR> | |
command! MLFatalLog edit ~/AirStreamData/Logs/Fatal.log<CR> | |
command! MLBashConfig edit ~/Dropbox/bin/bashrc_MobileLabs.sh<CR> | |
endif | |
" Append modeline after last line in buffer. | |
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX | |
" files. | |
" Credit: <http://vim.wikia.com/wiki/Modeline_magic> | |
function! AppendModeline() | |
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", | |
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') | |
let l:modeline = substitute(&commentstring, "%s", l:modeline, "") | |
call append(line("$"), l:modeline) | |
endfunction | |
command! AppendModeline call AppendModeline() | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. Only define it when not | |
" defined already. | |
if !exists(":DiffOrig") | |
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
endif | |
" Autocommands {{{1 | |
if has("autocmd") | |
filetype plugin indent on | |
augroup vimrcEx | |
au! | |
autocmd BufReadPre,FileReadPre ~/*vimrc execute 'setlocal foldcolumn=' . g:kj_foldcolumn . ' foldmethod=marker' | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event | |
" handler (happens when dropping a file on gvim). Also don't do it | |
" when the mark is in the first line, that is the default position | |
" when opening a file. | |
autocmd BufReadPost * | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
augroup END | |
else | |
set autoindent " always set autoindenting on | |
endif " has("autocmd") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment