Skip to content

Instantly share code, notes, and snippets.

Last active Apr 9, 2018
What would you like to do?
--regex-Css=/^[ \t]*(.+)[ \t]*\{/\1/f,functions/
--regex-Css=/^[ \t]*(.+)[ \t]*,[ \t]*$/\1/f,functions/
--regex-Css=/^[ \t]*([#.]*[a-zA-Z_0-9]+)[ \t]*$/\1/f,functions/
--regex-Html=/ng-([a-zA-Z0-9.$]+)=('|")(.*)('|")/ng-\1 \3/d,directives/
--regex-Html=/^[ \t]*<([a-zA-Z0-9.$]+)[ \t]*.*>/<\1>/t,tags/
--regex-Json=/^[ \t]*"([^"]+)"[ \t]*\:/\1/f,function/
--regex-make=/^([^# \t]*):/\1/t,target/
--regex-markdown=/^#[ \t]+(.*)/\1/h,H1/
--regex-markdown=/^##[ \t]+(.*)/\1/i,H2/
--regex-markdown=/^###[ \t]+(.*)/\1/j,H3/
--regex-markdown=/^####[ \t]+(.*)/\1/k,H4/
--regex-markdown=/^#####[ \t]+(.*)/\1/l,H5/
--regex-markdown=/^######[ \t]+(.*)/\1/m,H6/
--regex-javascript=/^[ \t]*(export([ \t]+abstract)?)?[ \t]*class[ \t]+([a-zA-Z0-9_$]+)/\3/c,classes/
--regex-javascript=/^[ \t]*(declare)?[ \t]*namespace[ \t]+([a-zA-Z0-9_$]+)/\2/c,modules/
--regex-javascript=/^[ \t]*(export)?[ \t]*module[ \t]+([a-zA-Z0-9_$]+)/\2/n,modules/
--regex-javascript=/^[ \t]*(export)?[ \t]*function[ \t]+([a-zA-Z0-9_$]+)/\2/f,functions/
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([a-zA-Z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(\)/\2/f,functions/
--regex-javascript=/^[ \t]*([a-zA-Z0-9_$]{3,})[ \t]*\(([a-zA-Z0-9_$,='" ]*)\)[ \t]*\{/\1/M,methods/
--regex-javascript=/^[ \t]*(export)?[ \t]*(public|protected|private)[ \t]+(static)?[ \t]*([a-zA-Z0-9_$]+)/\4/m,members/
--regex-javascript=/^[ \t]*(export)?[ \t]*interface[ \t]+([a-zA-Z0-9_$]+)/\2/i,interfaces/
--regex-javascript=/^[ \t]*(export)?[ \t]*type[ \t]+([a-zA-Z0-9_$]+)/\2/t,types/
--regex-javascript=/^[ \t]*(export)?[ \t]*enum[ \t]+([a-zA-Z0-9_$]+)/\2/e,enums/
--regex-javascript=/^[ \t]*import[ \t]+\{?([a-zA-Z0-9_$]+)\}?/\1/I,imports/
--regex-javascript=/^[ \t]*import[ \t]+([a-zA-Z0-9_$*]+)[ \t]+as[ \t]+([a-zA-Z0-9_$]+)/\2/I,imports/
--regex-typescript=/^[ \t]*(export([ \t]+abstract)?)?[ \t]*class[ \t]+([a-zA-Z0-9_$]+)/\3/c,classes/
--regex-typescript=/^[ \t]*(declare)?[ \t]*namespace[ \t]+([a-zA-Z0-9_$]+)/\2/c,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*module[ \t]+([a-zA-Z0-9_$]+)/\2/n,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*function[ \t]+([a-zA-Z0-9_$]+)/\2/f,functions/
--regex-typescript=/^[ \t]*(var|let|const)[ \t]+([a-zA-Z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(\)/\2/f,functions/
--regex-typescript=/^[ \t]*(export)?[ \t]*(public|protected|private)?[ \t]+(static)?[ \t]*([a-zA-Z0-9_$]{4,})[ \t]*\(/\4/m,members/
--regex-typescript=/^[ \t]*(export)?[ \t]*interface[ \t]+([a-zA-Z0-9_$]+)/\2/i,interfaces/
--regex-typescript=/^[ \t]*(export)?[ \t]*type[ \t]+([a-zA-Z0-9_$]+)/\2/t,types/
--regex-typescript=/^[ \t]*(export)?[ \t]*enum[ \t]+([a-zA-Z0-9_$]+)/\2/e,enums/
--regex-typescript=/^[ \t]*import[ \t]+\{?([a-zA-Z0-9_$]+)\}?/\1/I,imports/
--regex-typescript=/^[ \t]*import[ \t]+([a-zA-Z0-9_$*]+)[ \t]+as[ \t]+([a-zA-Z0-9_$]+)/\2/I,imports/
--regex-typescript=/^[ \t]*@([a-zA-Z0-9_$]+)/\1/d,decorators/
--regex-Yaml=/^[ \t]*([a-zA-Z_0-9 ]+)[ \t]*\:[ \t]*/\1/f,functions/
--regex-Yaml=/^[ \t]*- name:(.*)/\1/t,tasks/
"Enable filetype detection
set nocompatible "We're running Vim, no Vi!
filetype on "Enable filetype detection
filetype indent on "Enable filetype-specific indenting
filetype plugin on "Enable filetype-specific plugins
syntax enable "Enable syntax highlighting
"General settings
set encoding=utf-8 "Set encoding to UTF-8
set termencoding=utf-8 "Set terminal encoding to UTF-8
set maxmempattern=8192 "Increase memory for pattern matching
set backupcopy=yes "Disable safe write to allow code watchers
set incsearch "Find as you type
set ignorecase "Ignore case in search
set scrolloff=8 "Number of lines to keep above/below cursor
set smartcase "Only ignore case when all letters are lowercase
set number "Show line numbers
set modeline
set modelines=5
"set wildmode=longest,list "Complete longest string, then list alternatives
set fileformats=unix "Use Unix line endings
set smartindent "Smart autoindenting on new line
set smarttab "Respect space/tab settings
set history=300 "Number of commands to remember
set showmode "Show whether in Visual, Replace, or Insert Mode
set showmatch "Show matching brackets/parentheses
set backspace=2 "Use standard backspace behavior
set hlsearch "Highlight matches in search
set ruler "Show line and column number
set colorcolumn=100 "Draw a vertical line
set formatoptions=1 "Don't wrap text after a one-letter word
set nowrap "Don't wrap text
set linebreak "Break lines when appropriate
set expandtab "Tab key inserts spaces
set tabstop=2 "Use two spaces for tabs
set shiftwidth=2 "Use two spaces for auto-indent
set autoindent "Auto indent based on previous line
set hidden "Allow unsaved buffers
" set foldmethod=syntax
set wildignore+=*/tmp/*,*\\tmp\\*,*.so,*.swp,*.zip,*.exe,*.o
"Highlight long comments
highlight ExtraWhitespace ctermbg=red guibg=red
let a = matchadd('ExtraWhitespace', '\s\+$')
"Highlight trailing whitespaces
highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
let b = matchadd('OverLength', '\(^\(\s\)\{-}\(*\|//\|/\*\)\{1}\(.\)*\(\%81v\)\)\@<=\(.\)\{1,}$')
"Highlight tabs
set list lcs=tab:\ \
"Recognize QML files
au BufNewFile,BufRead *.qml set filetype=qml
"Load plugins
call plug#begin()
"General plugins
Plug 'altercation/vim-colors-solarized' "Color scheme
Plug 'tpope/vim-sensible' "Sensible defaults for programming
Plug 'justinmk/vim-sneak' "Two-character motion:
"[num]s{char}{char} -> jump to {char}, restrict to [num] columns
"; -> next
"S -> backward
"File/Buffer management
Plug 'ctrlpvim/ctrlp.vim' "Fuzzy file-search
"Ctrl+P -> search for filename in current tree
"[Enter] -> Open file in current buffer
"Ctrl+S -> Open file in split
Plug 'vim-airline/vim-airline' "Status line
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree' "File tree
Plug 'qpkorr/vim-bufkill' "Kills buffers without screwing stuff up
":BD -> delete file from buffer
":BW -> wipe file from buffer
":BUN -> unload file from buffer
"Git integration
Plug 'tpope/vim-fugitive' "Git wrapper
":G{command} [args] -> `git command args`
Plug 'airblade/vim-gitgutter' "Display git status in file gutter
Plug 'tpope/vim-rhubarb' "Allows :Gbrowse for GitHub
"Code helpers
Plug 'majutsushi/tagbar' " Display code tags in a split screen
Plug 'w0rp/ale' " Asynchronous Lint Engine
Plug 'tpope/vim-surround' "Surround character groups
"cs{char}{char} -> change surrounding from {char} to {char}
"ds{char} -> remove {char} surrounding
"ys{motion}{char} -> surround {motion} with {char}
"{motion} -> [num]w -> next [num] words
"{motion} -> z{char}{char} -> up until before {char}{char}
"Visual, S{tag} -> surround selection with {tag} (HTML, XML, etc.)
Plug 'tacahiroy/ctrlp-funky' "Function navigator
Plug 'jiangmiao/auto-pairs' "Automatically pairs brackets, parentheses, quotes, etc.
Plug 'bronson/vim-trailing-whitespace' "Highlight trailing spaces
Plug 'tomtom/tcomment_vim' "Comment toggle
"gc{motion} -> toggle comments for region
"gcc -> toggle comments for current line
"g<{motion} -> uncomment region
"g>{motion} -> comment region
"{motion} -> % -> up until matching bracket
"{motion} -> z{char}{char} -> up until before {char}{char}
Plug 'tpope/vim-sleuth' "Automatically set indent options
Plug 'xolox/vim-misc' "vim-easytags dependency
Plug 'xolox/vim-easytags' "automatic tag generation with exuberant-ctags
Plug 'lfilho/cosco.vim' "Comma/Semicolon bliss...
Plug 'sheerun/vim-polyglot'
Plug 'Quramy/vim-js-pretty-template'
Plug 'ap/vim-css-color'
Plug 'vim-scripts/gtk-vim-syntax', { 'for': 'c' }
Plug 'moll/vim-node', { 'for': 'javascript,typescript,javascript.jsx' } "Node.js
"gf -> Jump to file in path
"[I -> search for keywords in file
":Nedit {module} -> Edit module file
":Nopen {module} -> Open module file
Plug 'Valloric/MatchTagAlways'
Plug 'docunext/closetag.vim'
call plug#end()
"Custom key mappings
map <S-u> :redo<cr>
map <C-f> :NERDTreeToggle<CR>
map <S-f> :NERDTreeFind<CR>
map <F12> :TagbarToggle<CR>
" Find git conflicts in current buffer
map <C-g> /[<=>]\{7\}<CR>
" Faster scroll
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Buffer navigation
nnoremap <C-PageUp> :bprev<CR>
nnoremap <C-PageDown> :bnext<CR>
"Jump to the last position when reopening a file
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"Close vim if the only window left open is a NERDTree
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"Highlight current buffer in NERDTree
autocmd BufEnter *.* if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1 && expand("%:p:h") !~ '^/tmp' && bufnr('%') != bufnr('Tagbar')) | NERDTreeFind | wincmd p | endif
"Automatically add pretty template strings on ECMAScript
autocmd FileType javascript JsPreTmpl html
autocmd FileType typescript JsPreTmpl html
autocmd FileType typescript syn clear foldBraces
"Automatically highlight SCSS functions
autocmd FileType scss set iskeyword+=-
"Fix Ggrep on Windows
autocmd QuickFixCmdPost *grep* cwindow
"Insert commas or semicolons in the correct place
" let g:auto_comma_or_semicolon = 1
let g:cosco_ignore_comment_lines = 1
inoremap ;; <C-o>:CommaOrSemiColon<CR>
nnoremap ;; :CommaOrSemiColon<CR>
" nnoremap ,, :CommaOrSemiColon<CR>
"Enable autocomplete
let g:ale_completion_enabled = 1
" ALE linter for TypeScript is broken
let g:ale_linters = {
\ 'typescript': []
\ }
let g:ale_fixers = {
\ 'javascript': ['eslint']
\ }
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = '\v[\/]\.?(git|hg|svn|node_modules|bower_components|dist|tmp|typings|vendor)$'
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("h")': ['<c-i>'],
\ 'AcceptSelection("v")': ['<c-s>', '<c-cr>']
\ }
let g:jsx_ext_required = 0
let g:airline#extensions#default#layout = [
\ ['a', 'b', 'c'],
\ ['z', 'error', 'warning']
let g:airline_section_c = '%<%t%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
let g:airline_section_z = '%#__accent_bold#%4l%#__restore__#%#__restore__#%#__accent_bold#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__#%#__restore__# :%3v'
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tagbar#enabled = 0
let g:airline#extensions#tabline#enabled = 1
let g:tagbar_autoshowtag = 1
let g:tagbar_type_css = {
\ 'ctagstype' : 'Css',
\ 'kinds' : [
\ 'c:classes',
\ 's:selectors',
\ 'i:identities',
\ 'f:functions'
\ ]
\ }
let g:tagbar_type_html = {
\ 'ctagstype': 'Html',
\ 'kinds': [
\ 'd:directives',
\ 'b:bindings',
\ 'f:functions',
\ 't:tags'
let g:tagbar_type_make = {
\ 'kinds':[
\ 'm:macros',
\ 't:targets'
\ ]
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:H1',
\ 'i:H2',
\ 'j:H3',
\ 'k:H4',
\ 'l:H5',
\ 'm:H6'
\ ]
\ }
let g:tagbar_type_typescript = {
\ 'ctagstype': 'typescript',
\ 'kinds': [
\ 'c:classes',
\ 'n:modules',
\ 'f:functions',
\ 'm:members',
\ 'i:interfaces',
\ 't:types',
\ 'e:enums',
\ 'd:decorators',
\ 'I:imports'
\ ]
\ }
let g:tagbar_type_javascript = {
\ 'ctagstype': 'javascript',
\ 'kinds': [
\ 'c:classes',
\ 'M:methods',
\ 'n:modules',
\ 'f:functions',
\ 'm:members',
\ 'i:interfaces',
\ 't:types',
\ 'e:enums',
\ 'I:imports',
\ ]
\ }
let g:tagbar_type_yaml = {
\ 'ctagstype' : 'Yaml',
\ 'kinds' : [
\ 't:tasks',
\ 'f:functions'
\ ],
\ 'sort' : 0
\ }
let g:NERDTreeWinSize = 40 " Force window size
let g:NERDTreeChDirMode = 2 " Follow CWD
let g:NERDTreeShowHidden = 1 " Display hidden files
let g:NERDTreeShowBookmarks = 1 " Show bookmarks
let g:NERDTreeIgnore = ['\.git$[[dir]]', '\~$', '\.swp$', '\.tmp$[[dir]]', '^typings$[[dir]]', '^node_modules$[[dir]]', '.*\.o$']
" NERDTrees File highlighting
function! NERDTreeHighlightFile(extension, fg, guifg)
exec 'autocmd filetype nerdtree highlight ' . a:extension . ' ctermfg=' . a:fg . ' guifg=' . a:guifg
exec 'autocmd filetype nerdtree syn match ' . a:extension . ' #^\s\+.*' . a:extension . '$#'
" Config
let s:yellow = "#b58900"
call NERDTreeHighlightFile('ini', 'yellow', s:yellow)
call NERDTreeHighlightFile('md', 'yellow', s:yellow)
call NERDTreeHighlightFile('yml', 'yellow', s:yellow)
call NERDTreeHighlightFile('config', 'yellow', s:yellow)
call NERDTreeHighlightFile('conf', 'yellow', s:yellow)
call NERDTreeHighlightFile('json', 'yellow', s:yellow)
" Scripts
let s:red = "#dc3221"
call NERDTreeHighlightFile('coffee', 'red', s:red)
call NERDTreeHighlightFile('ts', 'red', s:red)
call NERDTreeHighlightFile('js', 'red', s:red)
call NERDTreeHighlightFile('php', 'red', s:red)
" Styles
let s:cyan = "#2aa198"
call NERDTreeHighlightFile('styl', 'cyan', s:cyan)
call NERDTreeHighlightFile('css', 'cyan', s:cyan)
" Templates
let s:green = "#859900"
call NERDTreeHighlightFile('jade', 'green', s:green)
call NERDTreeHighlightFile('html', 'green', s:green)
call NERDTreeHighlightFile('pug', 'green', s:green)
" System
let s:magenta = "#6c71c4"
call NERDTreeHighlightFile('bash', 'magenta', s:magenta)
if has("gui_running")
colorscheme solarized
set background=light
let g:airline_theme='solarized'
let g:solarized_term = 1
highlight MatchParen ctermbg=NONE ctermfg=Red guibg=NONE guifg=Red
"Open Tagbar automatically
autocmd VimEnter * TagbarOpen
"Open NERD tree automatically
autocmd VimEnter * NERDTree
"Move cursor to empty buffer
" autocmd VimEnter * wincmd p
"Hide toolbar and menu
set guioptions -=T
" set guioptions -=m
:cd ~/dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment