Last active
December 11, 2020 21:31
-
-
Save rexagod/5aad7dd3bc68ec426dac9e19469d3ea2 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/vim | |
" Vim is a lot like Javascript: it allows you to play fast and loose with types{{{ | |
" sometimes, but it's a really bad idea to do so because it will come back to | |
" bite you at some point. | |
" ~ Steve Losh.}}} | |
" Author: @rexagod | |
" Plugins | |
call plug#begin('~/.vim/plugged') | |
" Text Manipulations {{{ | |
Plug 'godlygeek/tabular' | |
Plug 'matze/vim-move' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-surround' | |
" }}} | |
" Navigation {{{ | |
Plug 'justinmk/vim-sneak' | |
Plug 'preservim/tagbar' | |
Plug 'preservim/nerdtree' | | |
\ Plug 'Xuyuanp/nerdtree-git-plugin' | | |
\ Plug 'ryanoasis/vim-devicons' | |
" }}} | |
" Visuals {{{ | |
Plug 'noah/vim256-color' | |
Plug 'editorconfig/editorconfig-vim' | |
" }}} | |
" Git {{{ | |
Plug 'mattn/webapi-vim' | | |
\ Plug 'mattn/vim-gist' | |
Plug 'tpope/vim-fugitive' | | |
\ Plug 'tpope/vim-rhubarb' | |
" }}} | |
call plug#end() | |
" Autocommands {{{ | |
au Filetype help nn<buffer>q :q<cr> | |
au BufWinEnter *.* silent! loadview | |
au BufWinLeave *.* mkview | |
" }}} | |
" Maps {{{ | |
let mapleader="\<Space>" | |
" nvim changes runtimepath for $MYVIMRC | |
nn <leader>vr :vsp ~/.vimrc<cr> | |
nn <leader>so :if &modifiable<bar>w<bar>endif<bar>source %<cr> | |
nn <leader>br :vsp $MYBASHRC<cr> | |
nn <leader>rn :set rnu!<cr> | |
nn o o<esc> | |
nn O O<esc> | |
nn <leader>ss :set invspell<cr> | |
im <C-d> <esc>ddi | |
nn <C-b> :ls<cr>:b<space> | |
nn <leader>rg :reg<cr> | |
nn <tab> | |
\ :if &modifiable && | |
\ !&readonly && | |
\ &modified<cr> | |
\ :w<cr> | |
\ :endif<cr> | |
\ :bn<cr> | |
nn <s-tab> | |
\ :if &modifiable && | |
\ !&readonly && | |
\ &modified<cr> | |
\ :w<cr> | |
\ :endif<cr> | |
\ :bp<cr> | |
au Filetype vim,bash let maplocalleader="\\" | |
" }}} | |
" Aliases {{{ | |
com! QQ qall | |
" }}} | |
" Theme {{{ | |
colo cobalt2 | |
" }}} | |
" Statusline {{{ | |
hi StatusLine ctermbg=Black ctermfg=White | |
set laststatus=2 | |
set statusline=%f\ %m%=%y\ %r%{FugitiveStatusline()}\ [%l,%c%V]\ %3p%{nr2char(37)}%< | |
" }}} | |
" Options {{{ | |
set background=dark | |
set confirm | |
set expandtab smarttab tabstop=2 shiftwidth=2 smartindent | |
set fdm=marker | |
set nobackup noswapfile | |
set nowrap | |
set nu rnu ruler title wildmenu | |
set showcmd | |
set showmatch matchtime=2 | |
set textwidth=80 | |
" }}} | |
" Plugin Configurations {{{ | |
" vim-sneak | |
let g:sneak#label=1 | |
let g:sneak#f_reset = 1 | |
let g:sneak#t_reset = 1 | |
" tagbar | |
" let g:tagbar_show_data_type=1 | |
let g:tagbar_autofocus=1 | |
let g:tagbar_compact=1 | |
let g:tagbar_iconchars=['▷', '◢'] | |
let g:tagbar_indent=1 | |
let g:tagbar_show_tag_count=1 | |
let g:tagbar_show_tag_linenumbers=2 | |
let g:tagbar_sort=0 | |
let g:tagbar_wrap=1 | |
let g:tagbar_zoomwidth=0 | |
nn <leader><space> :TagbarOpenAutoClose<cr> | |
" editorconfig-vim | |
let g:EditorConfig_exclude_patterns=['fugitive://.*', 'scp://.*'] | |
" vim-move | |
let g:move_key_modifier='C' | |
" vim-fugitive | |
au BufReadPost fugitive://* set bufhidden=delete | |
" nerdtree | |
let NERDTreeMinimalUI=1 | |
let NERDTreeDirArrows=1 | |
let NERDTreeCustomOpenArgs={'file':{'where':'p','keepopen':1,'stay':1}} | |
nn <C-n> :NERDTreeToggle<cr> | |
au FileType nerdtree nm <cr> go | |
" }}} | |
" Workarounds | |
" WSL Yank Support {{{ | |
let s:clip='/mnt/c/Windows/System32/clip.exe' | |
if executable(s:clip) | |
aug WSLYank | |
au! | |
au TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif | |
aug END | |
endif | |
" }}} | |
" Notes | |
" use <C-v>, <C-k> for recording normal/vim keybindings. | |
" use <C-e>, <C-y> for padded move. | |
" use <C-m> for newline in i-mode. | |
" surrounds: ys<select><x>, yS<select><x> (indents), cs<x><y>, ds<x>. Use open braces for padding (ys/yS commands), y{ss/SS} for selecting whole line. | |
" to create fixup! commit cf w.r.t. the faulty commit, then :Glog and ri on the faulty commit, replace pick -> fixup in front of the fixup commit. | |
" make sure both faulty and fixup commits are visible in the rebase window. | |
" <C-{/}>, :buf <n> to move faster. K for definitions.=to indent. | |
" ce to amend staged hunks w/o changing previous commit (alt - ca). Prefer cc instead of C for committing staged hunks. | |
" Gedit# to go back from log menu to file. c{open/close} for commit window. | |
" folds: <n>zf,zo,zc,zd,zn,zN,fold,foldopen,foldclose,zE. {-x,+y} - relative selection. | |
" T,F to search backwards. setlocal for local settings. | |
" *map -- *noremap -- *unmap (im -- in -- iu, nm -- nn -- nun, vm -- vn -- vu). See map-modes for more. | |
" au FileType fortran let maplocalleader="`" | |
" use <buffer> in mappings to define those mappings for the current buffer only, e.g., nn <buffer><localleader>Q dd | |
" in case of similar mappings, vim goes with the more "specific" one (shadowing). | |
" g_ and _ for start/end of line. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment