Last active
March 26, 2019 18:50
-
-
Save LearningNerd/64d586a024f718ad1bc208484d7398a7 to your computer and use it in GitHub Desktop.
My current vimrc file! A lot of this stuff is junk, some won't work out of the box (I forgot I DO have a plugin named AsyncRun and some stuff references a command line tool named grip), but maybe the key binding, search, autocompletion, and some of the other commands will be helpful :)
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
" Vim Code Dark (color scheme) | |
" with some customizations by Liz | |
" https://github.com/tomasiser/vim-code-dark | |
" | |
" NOTE: PUT THIS INSIDE A /colors FOLDER!!! | |
" My directory structure is like: | |
" .vim/ folder contains: | |
" vimrc (file, notice there's no . before the name) | |
" colors/ folder containing several color themes, including this one | |
scriptencoding utf-8 | |
set background=dark | |
hi clear | |
if exists("syntax_on") | |
syntax reset | |
endif | |
let g:colors_name="codedark" | |
" Highlighting function (inspiration from https://github.com/chriskempson/base16-vim) | |
if &t_Co >= 256 | |
let g:codedark_term256=1 | |
elseif !exists("g:codedark_term256") | |
let g:codedark_term256=0 | |
endif | |
fun! <sid>hi(group, fg, bg, attr, sp) | |
if !empty(a:fg) | |
exec "hi " . a:group . " guifg=" . a:fg.gui . " ctermfg=" . (g:codedark_term256 ? a:fg.cterm256 : a:fg.cterm) | |
endif | |
if !empty(a:bg) | |
exec "hi " . a:group . " guibg=" . a:bg.gui . " ctermbg=" . (g:codedark_term256 ? a:bg.cterm256 : a:bg.cterm) | |
endif | |
if a:attr != "" | |
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr | |
endif | |
if !empty(a:sp) | |
exec "hi " . a:group . " guisp=" . a:sp.gui | |
endif | |
endfun | |
" ------------------ | |
" Color definitions: | |
" ------------------ | |
" Terminal colors (base16): | |
let s:cterm00 = "00" | |
let s:cterm03 = "08" | |
let s:cterm05 = "07" | |
let s:cterm07 = "15" | |
let s:cterm08 = "01" | |
let s:cterm0A = "03" | |
let s:cterm0B = "02" | |
let s:cterm0C = "06" | |
let s:cterm0D = "04" | |
let s:cterm0E = "05" | |
if exists('base16colorspace') && base16colorspace == "256" | |
let s:cterm01 = "18" | |
let s:cterm02 = "19" | |
let s:cterm04 = "20" | |
let s:cterm06 = "21" | |
let s:cterm09 = "16" | |
let s:cterm0F = "17" | |
else | |
let s:cterm01 = "00" | |
let s:cterm02 = "08" | |
let s:cterm04 = "07" | |
let s:cterm06 = "07" | |
let s:cterm09 = "06" | |
let s:cterm0F = "03" | |
endif | |
" General appearance colors: | |
" (some of them may be unused) | |
let s:cdNone = {'gui': 'NONE', 'cterm': 'NONE', 'cterm256': 'NONE'} | |
let s:cdFront = {'gui': '#D4D4D4', 'cterm': s:cterm05, 'cterm256': '188'} | |
let s:cdBack = {'gui': '#1E1E1E', 'cterm': s:cterm00, 'cterm256': '234'} | |
let s:cdTabCurrent = {'gui': '#1E1E1E', 'cterm': s:cterm00, 'cterm256': '234'} | |
let s:cdTabOther = {'gui': '#2D2D2D', 'cterm': s:cterm01, 'cterm256': '236'} | |
let s:cdTabOutside = {'gui': '#252526', 'cterm': s:cterm01, 'cterm256': '235'} | |
let s:cdLeftDark = {'gui': '#252526', 'cterm': s:cterm01, 'cterm256': '235'} | |
let s:cdLeftMid = {'gui': '#373737', 'cterm': s:cterm03, 'cterm256': '237'} | |
let s:cdLeftLight = {'gui': '#3F3F46', 'cterm': s:cterm03, 'cterm256': '238'} | |
let s:cdPopupFront = {'gui': '#BBBBBB', 'cterm': s:cterm06, 'cterm256': '250'} | |
let s:cdPopupBack = {'gui': '#2D2D30', 'cterm': s:cterm01, 'cterm256': '236'} | |
let s:cdPopupHighlightBlue = {'gui': '#073655', 'cterm': s:cterm0D, 'cterm256': '24'} | |
let s:cdPopupHighlightGray = {'gui': '#3D3D40', 'cterm': s:cterm03, 'cterm256': '237'} | |
let s:cdSplitLight = {'gui': '#898989', 'cterm': s:cterm04, 'cterm256': '245'} | |
let s:cdSplitDark = {'gui': '#444444', 'cterm': s:cterm03, 'cterm256': '238'} | |
let s:cdSplitThumb = {'gui': '#424242', 'cterm': s:cterm04, 'cterm256': '238'} | |
let s:cdCursorDarkDark = {'gui': '#222222', 'cterm': s:cterm01, 'cterm256': '235'} | |
let s:cdCursorDark = {'gui': '#51504F', 'cterm': s:cterm03, 'cterm256': '239'} | |
let s:cdCursorLight = {'gui': '#AEAFAD', 'cterm': s:cterm04, 'cterm256': '145'} | |
let s:cdSelection = {'gui': '#264F78', 'cterm': s:cterm03, 'cterm256': '24'} | |
let s:cdLineNumber = {'gui': '#5A5A5A', 'cterm': s:cterm04, 'cterm256': '240'} | |
let s:cdDiffRedDark = {'gui': '#4B1818', 'cterm': s:cterm08, 'cterm256': '52'} | |
let s:cdDiffRedLight = {'gui': '#6F1313', 'cterm': s:cterm08, 'cterm256': '52'} | |
let s:cdDiffRedLightLight = {'gui': '#FB0101', 'cterm': s:cterm08, 'cterm256': '09'} | |
let s:cdDiffGreenDark = {'gui': '#373D29', 'cterm': s:cterm0B, 'cterm256': '237'} | |
let s:cdDiffGreenLight = {'gui': '#4B5632', 'cterm': s:cterm09, 'cterm256': '58'} | |
let s:cdSearchCurrent = {'gui': '#49545F', 'cterm': s:cterm09, 'cterm256': '239'} | |
let s:cdSearch = {'gui': '#4C4E50', 'cterm': s:cterm0A, 'cterm256': '239'} | |
" Syntax colors: | |
if !exists("g:codedark_conservative") | |
let g:codedark_conservative=0 | |
endif | |
let s:cdGray = {'gui': '#808080', 'cterm': s:cterm04, 'cterm256': '08'} | |
let s:cdViolet = {'gui': '#646695', 'cterm': s:cterm04, 'cterm256': '60'} | |
let s:cdBlue = {'gui': '#569CD6', 'cterm': s:cterm0D, 'cterm256': '75'} | |
let s:cdDarkBlue = {'gui': '#223E55', 'cterm': s:cterm0D, 'cterm256': '73'} | |
let s:cdLightBlue = {'gui': '#9CDCFE', 'cterm': s:cterm0C, 'cterm256': '117'} | |
if g:codedark_conservative | let s:cdLightBlue = s:cdFront | endif | |
let s:cdGreen = {'gui': '#608B4E', 'cterm': s:cterm0B, 'cterm256': '65'} | |
let s:cdBlueGreen = {'gui': '#4EC9B0', 'cterm': s:cterm0F, 'cterm256': '43'} | |
let s:cdLightGreen = {'gui': '#B5CEA8', 'cterm': s:cterm09, 'cterm256': '151'} | |
let s:cdRed = {'gui': '#F44747', 'cterm': s:cterm08, 'cterm256': '203'} | |
let s:cdOrange = {'gui': '#CE9178', 'cterm': s:cterm0F, 'cterm256': '173'} | |
let s:cdLightRed = {'gui': '#D16969', 'cterm': s:cterm08, 'cterm256': '167'} | |
if g:codedark_conservative | let s:cdLightRed = s:cdOrange | endif | |
let s:cdYellowOrange = {'gui': '#D7BA7D', 'cterm': s:cterm0A, 'cterm256': '179'} | |
let s:cdYellow = {'gui': '#DCDCAA', 'cterm': s:cterm0A, 'cterm256': '187'} | |
if g:codedark_conservative | let s:cdYellow = s:cdFront | endif | |
let s:cdPink = {'gui': '#C586C0', 'cterm': s:cterm0E, 'cterm256': '176'} | |
if g:codedark_conservative | let s:cdPink = s:cdBlue | endif | |
" Vim editor colors | |
" <sid>hi(GROUP, FOREGROUND, BACKGROUND, ATTRIBUTE, SPECIAL) | |
call <sid>hi('Normal', s:cdFront, s:cdBack, 'none', {}) | |
call <sid>hi('ColorColumn', {}, s:cdCursorDarkDark, 'none', {}) | |
call <sid>hi('Cursor', s:cdCursorDark, s:cdCursorLight, 'none', {}) | |
call <sid>hi('CursorLine', {}, s:cdCursorDarkDark, 'none', {}) | |
call <sid>hi('Directory', s:cdBlue, s:cdBack, 'none', {}) | |
call <sid>hi('DiffAdd', {}, s:cdDiffGreenDark, 'none', {}) | |
call <sid>hi('DiffChange', {}, s:cdDiffRedDark, 'none', {}) | |
call <sid>hi('DiffDelete', {}, s:cdDiffRedLight, 'none', {}) | |
call <sid>hi('DiffText', {}, s:cdDiffRedLight, 'none', {}) | |
call <sid>hi('EndOfBuffer', s:cdLineNumber, s:cdBack, 'none', {}) | |
call <sid>hi('ErrorMsg', s:cdRed, s:cdBack, 'none', {}) | |
call <sid>hi('VertSplit', s:cdSplitDark, s:cdBack, 'none', {}) | |
call <sid>hi('Folded', s:cdLeftLight, s:cdLeftDark, 'underline', {}) | |
call <sid>hi('FoldColumn', s:cdLineNumber, s:cdBack, 'none', {}) | |
call <sid>hi('SignColumn', {}, s:cdBack, 'none', {}) | |
call <sid>hi('IncSearch', s:cdNone, s:cdSearchCurrent, 'none', {}) | |
call <sid>hi('LineNr', s:cdLineNumber, s:cdBack, 'none', {}) | |
call <sid>hi('CursorLineNr', s:cdPopupFront, s:cdBack, 'none', {}) | |
call <sid>hi('MatchParen', s:cdNone, s:cdCursorDark, 'none', {}) | |
call <sid>hi('ModeMsg', s:cdFront, s:cdLeftDark, 'none', {}) | |
call <sid>hi('MoreMsg', s:cdFront, s:cdLeftDark, 'none', {}) | |
call <sid>hi('NonText', s:cdLineNumber, s:cdBack, 'none', {}) | |
call <sid>hi('Pmenu', s:cdPopupFront, s:cdPopupBack, 'none', {}) | |
call <sid>hi('PmenuSel', s:cdPopupFront, s:cdPopupHighlightBlue, 'none', {}) | |
call <sid>hi('PmenuSbar', {}, s:cdPopupHighlightGray, 'none', {}) | |
call <sid>hi('PmenuThumb', {}, s:cdPopupFront, 'none', {}) | |
call <sid>hi('Question', s:cdBlue, s:cdBack, 'none', {}) | |
call <sid>hi('Search', s:cdNone, s:cdSearch, 'none', {}) | |
call <sid>hi('SpecialKey', s:cdBlue, s:cdNone, 'none', {}) | |
call <sid>hi('SpellBad', s:cdNone, s:cdNone, 'undercurl', {}) | |
call <sid>hi('SpellCap', s:cdNone, s:cdNone, 'undercurl', {}) | |
call <sid>hi('SpellLocal', s:cdNone, s:cdNone, 'undercurl', {}) | |
call <sid>hi('StatusLine', s:cdFront, s:cdLeftMid, 'none', {}) | |
call <sid>hi('StatusLineNC', s:cdFront, s:cdLeftDark, 'none', {}) | |
call <sid>hi('TabLine', s:cdFront, s:cdTabOther, 'none', {}) | |
call <sid>hi('TabLineFill', s:cdFront, s:cdTabOutside, 'none', {}) | |
call <sid>hi('TabLineSel', s:cdFront, s:cdTabCurrent, 'none', {}) | |
call <sid>hi('Title', s:cdGreen, s:cdNone, 'bold', {}) | |
call <sid>hi('Visual', s:cdNone, s:cdSelection, 'none', {}) | |
call <sid>hi('VisualNOS', s:cdNone, s:cdSelection, 'none', {}) | |
call <sid>hi('WarningMsg', s:cdOrange, s:cdBack, 'none', {}) | |
call <sid>hi('WildMenu', s:cdNone, s:cdSelection, 'none', {}) | |
call <sid>hi('Comment', s:cdGreen, {}, 'none', {}) | |
call <sid>hi('Constant', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('String', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('Character', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('Number', s:cdLightGreen, {}, 'none', {}) | |
call <sid>hi('Boolean', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('Float', s:cdLightGreen, {}, 'none', {}) | |
call <sid>hi('Identifier', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('Function', s:cdYellow, {}, 'none', {}) | |
call <sid>hi('Statement', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Conditional', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Repeat', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Label', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Operator', s:cdFront, {}, 'none', {}) | |
call <sid>hi('Keyword', s:cdPink, {}, 'none', {}) | |
call <sid>hi('pythonOperator', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Exception', s:cdPink, {}, 'none', {}) | |
call <sid>hi('PreProc', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Include', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Define', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Macro', s:cdPink, {}, 'none', {}) | |
call <sid>hi('PreCondit', s:cdPink, {}, 'none', {}) | |
call <sid>hi('Type', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('StorageClass', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('Structure', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('Typedef', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('Special', s:cdFront, {}, 'none', {}) | |
call <sid>hi('SpecialChar', s:cdFront, {}, 'none', {}) | |
call <sid>hi('Tag', s:cdFront, {}, 'none', {}) | |
call <sid>hi('Delimiter', s:cdFront, {}, 'none', {}) | |
call <sid>hi('SpecialComment', s:cdGreen, {}, 'none', {}) | |
call <sid>hi('Debug', s:cdFront, {}, 'none', {}) | |
call <sid>hi('Underlined', s:cdNone, {}, 'underline', {}) | |
call <sid>hi("Conceal", s:cdFront, s:cdBack, 'none', {}) | |
call <sid>hi('Ignore', s:cdFront, {}, 'none', {}) | |
call <sid>hi('Error', s:cdRed, {}, 'undercurl', s:cdRed) | |
call <sid>hi('Todo', s:cdNone, s:cdLeftMid, 'none', {}) | |
" HTML: | |
call <sid>hi('htmlTag', s:cdGray, {}, 'none', {}) | |
call <sid>hi('htmlEndTag', s:cdGray, {}, 'none', {}) | |
call <sid>hi('htmlTagName', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('htmlSpecialTagName', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('htmlArg', s:cdLightBlue, {}, 'none', {}) | |
" CSS: | |
call <sid>hi('cssBraces', s:cdFront, {}, 'none', {}) | |
call <sid>hi('cssInclude', s:cdPink, {}, 'none', {}) | |
call <sid>hi('cssTagName', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssClassName', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssPseudoClass', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssPseudoClassId', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssPseudoClassLang', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssIdentifier', s:cdYellowOrange, {}, 'none', {}) | |
call <sid>hi('cssProp', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('cssDefinition', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('cssAttr', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssAttrRegion', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssColor', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssFunction', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssFunctionName', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssVendor', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssValueNumber', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssValueLength', s:cdOrange, {}, 'none', {}) | |
call <sid>hi('cssUnitDecorators', s:cdOrange, {}, 'none', {}) | |
" JavaScript: | |
call <sid>hi('jsVariableDef', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('jsFuncArgs', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('jsRegexpString', s:cdLightRed, {}, 'none', {}) | |
call <sid>hi('jsThis', s:cdBlue, {}, 'none', {}) | |
" Ruby: | |
call <sid>hi('rubyClassNameTag', s:cdBlueGreen, {}, 'none', {}) | |
" Golang: | |
call <sid>hi('goPackage', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goImport', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goVar', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goConst', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goStatement', s:cdPink, {}, 'none', {}) | |
call <sid>hi('goType', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goSignedInts', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goUnsignedInts', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goFloats', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goComplexes', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goBuiltins', s:cdYellow, {}, 'none', {}) | |
call <sid>hi('goBoolean', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goPredefinedIdentifiers', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goTodo', s:cdGreen, {}, 'none', {}) | |
call <sid>hi('goDeclaration', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goDeclType', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goTypeDecl', s:cdBlue, {}, 'none', {}) | |
call <sid>hi('goTypeName', s:cdBlueGreen, {}, 'none', {}) | |
call <sid>hi('goVarAssign', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('goVarDefs', s:cdLightBlue, {}, 'none', {}) | |
call <sid>hi('goReceiver', s:cdFront, {}, 'none', {}) | |
call <sid>hi('goReceiverType', s:cdDarkBlue, {}, 'none', {}) | |
call <sid>hi('goFunctionCall', s:cdYellow, {}, 'none', {}) | |
call <sid>hi('goMethodCall', s:cdYellow, {}, 'none', {}) | |
call <sid>hi('goSingleDecl', s:cdLightBlue, {}, 'none', {}) |
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Liz's .vimrc file! :) Latest update: 2019-03-26 | |
" | |
" Sources | |
" https://dougblack.io/words/a-good-vimrc.html | |
" | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Some other cool thingies to try out? | |
" | |
" https://github.com/vim-airline/vim-airline | |
" https://github.com/powerline/powerline | |
" | |
" https://github.com/jiangmiao/auto-pairs | |
" | |
" Color schemes to try?: | |
" https://github.com/drewtempelmeyer/palenight.vim | |
" https://github.com/joshdick/onedark.vim | |
" https://github.com/morhetz/gruvbox | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" TEMPORARY-ISH STUFF | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Java Algorithms class macro for compile and run current file: | |
let @j = ':!clear && javac-algs4 % && java-algs4 %:r' | |
" Run jest test from within Vim and also pipe output to test file | |
" NOTE - or do tee -1 filename to append instead of overwrite! | |
let @t = ":!npm test | tee ~/Code/todo-timer/testoutput1.log\<CR>" | |
let @y = ":!npm test | tee ~/Code/todo-timer/testoutput2.log\<CR>" | |
let @r = ":!vimdiff ~/Code/todo-timer/testoutput1.log ~/Code/todo-timer/testoutput2.log\<CR>" | |
" Run Jest test from within Vim and open/reload file with test output | |
" **** Save this as a function so I can add a delay while test runs...... | |
" [ADD QUOTE HERE] :AsyncStop\<CR>:AsyncRun npm test | tee testoutput.log\<CR>:e testoutput.log\<CR>:AsyncStop [ADD QUOTE HERE] | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Basic UI (colors, spaces/tabs, syntax highlighting) | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
syntax on " Syntax highlighting on by default | |
set number " Enable line numbers! | |
set wrap linebreak | |
" CUSTOM COLOR SCHEME AND HIGHLIGHTING STUFF (OVERRIDES COLORSCHEME BELOW) | |
" NOTE -- now using GFM plugin: | |
" https://github.com/rhysd/vim-gfm-syntax | |
autocmd ColorScheme * highlight markdownH1 ctermfg=green | |
autocmd ColorScheme * highlight markdownH1Delimiter ctermfg=green | |
autocmd ColorScheme * highlight markdownH2 ctermfg=green | |
autocmd ColorScheme * highlight markdownH3 ctermfg=green | |
autocmd ColorScheme * highlight markdownH4 ctermfg=green | |
autocmd ColorScheme * highlight markdownH5 ctermfg=green | |
autocmd ColorScheme * highlight markdownH6 ctermfg=green | |
autocmd ColorScheme * highlight markdownHeadingDelimiter ctermfg=green | |
autocmd ColorScheme * highlight githubFlavoredMarkdownCode ctermfg=lightblue | |
" SET THE BASE COLORSCHEME | |
colorscheme codedark " Color scheme (see /colors folder!) | |
" INDENTATION | |
set tabstop=2 " Number of visual spaces in a TAB | |
set softtabstop=2 " Number of spaces in TAB when editing | |
set expandtab " Convert TABs to spaces | |
set shiftwidth=2 " Number of spaces to use per autoindent level | |
set cursorline " Highlight current line | |
set showmatch " highlight matching brackets | |
" DO call GetSyntax() to see what highlight settings belong to text under | |
" cursor | |
function! GetSyntaxID() | |
return synID(line('.'), col('.'), 1) | |
endfunction | |
function! GetSyntaxParentID() | |
return synIDtrans(GetSyntaxID()) | |
endfunction | |
function! GetSyntax() | |
echo synIDattr(GetSyntaxID(), 'name') | |
exec "hi ".synIDattr(GetSyntaxParentID(), 'name') | |
endfunction | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Commands and Functionality | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
set clipboard=unnamed " Use the system clipboard by default. Used brew instell vim and aliased vim to | |
" Used "brew install vim" and added this to my .profile to make this work: alias vim="/usr/local/bin/vim" | |
" To check for clipboard support (I now have +clipboard after the brew | |
" install), run this: vim --version | grep clipboard | |
set showcmd " Show most recent command | |
filetype plugin indent on " Load file-type specific plugins and indent files | |
set wildmenu " visual autocomplete for command menu | |
" set wildcharm=<C-z> " set Ctrl+z as the key for MARCOS that starts the wildmenu | |
" Autosave when leaving any buffer | |
set autowriteall | |
" Auto-save ALL open files every N milliseconds: | |
" maybe try adding silent! at the end to not show messages/errors ? | |
" maybe add event BufLeave to save automatically when closing a file | |
autocmd CursorHold * :wall | |
set updatetime=2000 | |
" Automatically leave insert mode after N milliseconds of inaction | |
autocmd CursorHoldI * stopinsert | |
" set 'updatetime' to 4 seconds when in insert mode | |
au InsertEnter * let updaterestore=&updatetime | set updatetime=4000 | |
au InsertLeave * let &updatetime=updaterestore | |
" If typing :W, just run :w -- typo fix! :) | |
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W')) | |
""""""""""""""""""""""" | |
" For autocompletion | |
""""""""""""""""""""""" | |
" Indent if we're at the beginning of a line. Else, do completion. | |
" https://github.com/garybernhardt/dotfiles/blob/master/.vimrc | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-p>" | |
endif | |
endfunction | |
inoremap <expr> <tab> InsertTabWrapper() | |
inoremap <s-tab> <c-n> | |
" Use the instant-markdown plugin via | |
" ***** Didn't like it, no emoji support. But I love the live reload. hrmph. | |
" https://github.com/suan/vim-instant-markdown | |
" set runtimepath^=~/.vim/after/ftplugin/markdown/instant-markdown.md | |
" Use the vim-livedown plugin via | |
" https://github.com/shime/vim-livedown | |
" ****** THE BELOW ARE NOT WORKING. So, not using it. :( | |
" let g:livedown_autorun = 0 | |
" let g:livedown_open = 1 | |
""""""""""""""""' | |
" For Markdown | |
" via https://github.com/tpope/vim-markdown | |
"""""""""""""" | |
" Use .md files as markdown files; not needed! (Maybe handled by GFM plugin?) | |
" autocmd BufNewFile,BufReadPost *.md set filetype=markdown " .md = .markdown | |
let g:markdown_fenced_languages = ['html', 'javascript', 'python', 'bash=sh'] " syntax highlight in ``` | |
" NOTE -- now using GFM plugin: | |
" https://github.com/rhysd/vim-gfm-syntax | |
" **** See above for custom color/highlighting | |
" *** NOTE -- Using modified tpope markdown syntax file in | |
" .vim/syntax/markdown.vim to manually remove bold/italic delimiters and | |
" highlighting, to avoid the ***bolditalic* onlybold** bug! | |
" Upon opening a Markdown file, call grip for GitHub markdown previews | |
" and open the preview in the browser (bypassing the Hit Enter to Continue) | |
" NOTE - the open -g flag opens an application in the background. Yay! | |
function! MarkPreview() | |
:AsyncStop | |
sleep 200m | |
:AsyncRun grip "%:p" --user="LearningNerd" --pass="5d801f59129d01ba8210f285625093260b11caf3" | |
sleep 200m | |
:silent !open -g http://localhost:6419/ | |
:redraw! | |
endfunction | |
" TURNED OFF -- automatically run grip and open preview upon opening a | |
" markdown file .... I don't always want to see a preview. Annoying. | |
" autocmd FileType markdown map :md call MarkPreview() | |
" So instead: type :Md and Enter to run the command. Now also stops any previous | |
" processes (like if grip was running for a different file). | |
command Md call MarkPreview()<CR> | |
" TO DO | |
" -- *** set this key binding ONLY for markdown files. | |
" -- run grip on a whole directory and tab through multiple preview | |
" pages??? | |
" TO TRY -- Open a skeleton file when opening a new file: | |
" **** how to open only for .md file in a specific folder????? | |
" :autocmd BufNewFile *.java 0r ~/vim/skeleton.md | |
""""""""""""""""" | |
" FOR NOTES | |
""""""""""""""" | |
" Open (in vertical split) the notes file for the current day, yesterday, or | |
" ... | |
command Today execute "vs ~/Notes/learning-notes/" . strftime("%F") . ".md" | |
command Yester execute "vs ~/Notes/learning-notes/" . strftime("%F", strftime("%s")-86400) . ".md" | |
" Expand expressions to date in yyyy-mm-dd format | |
cnoreabbrev <expr> today (strftime("%F")) | |
cnoreabbrev <expr> yesterday ( strftime("%F", strftime("%s")-86400) ) | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Searching | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set incsearch " search as characters are entered | |
set hlsearch " highlight matches | |
" Always keep cursor in center of screen | |
"set scrolloff=999 | |
" Always center screen on cursor when navigating search results | |
:nnoremap n nzz | |
:nnoremap N Nzz | |
:nnoremap * *zz | |
:nnoremap # #zz | |
:nnoremap g* g*zz | |
:nnoremap g# g#zz | |
" Change search highlight color to be a bit more obvious | |
hi Search ctermbg=White | |
hi Search ctermfg=Red | |
hi IncSearch ctermbg=Green | |
hi IncSearch ctermfg=White | |
" nnoremap <leader><space> :nohlsearch<CR> " turn off search highlight | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Key bindings | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Mini-hard mode: disable arrow keys! | |
noremap <Up> <NOP> | |
noremap <Down> <NOP> | |
noremap <Left> <NOP> | |
noremap <Right> <NOP | |
" IDEA -- use arrow keys to jump between split panes: | |
noremap <up> <C-w><up> | |
noremap <down> <C-w><down> | |
noremap <left> <C-w><left> | |
noremap <right> <C-w><right> | |
" Always move to next visually-wrapped line | |
nnoremap j gj | |
nnoremap k gk | |
" Highlight last inserted text | |
" nnoremap gV `[v`] | |
" jk is escape | |
inoremap jk <esc> | |
" copy selection to clipboard without copying to Vim | |
" vnoremap cx :w !pbcopy<CR><CR> | |
" OLD WORKAROUND, no longer needed: | |
" copy selection to clipboard AND copy to Vim (also yanks it) | |
" https://stackoverflow.com/questions/677986/vim-copy-selection-to-os-x-clipboard | |
" noremap cx y:e ~/clipsongzboard<CR>P:w !pbcopy<CR><CR>:bdelete!<CR> | |
" nnoremap xv :r !pbpaste<CR><CR> " paste clipboard | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment