vimrc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. """"" My (demuredemeanor) .vimrc
  2. "" Uses tabstop=4; shiftwidth=4; foldmarker={{{,}}};
  3. """"""""vim: set tabstop=4 shiftwidth=4:
  4. "" Above is an attempt at a modeline, which seems to have a issue
  5. "" where long pastes get a new line...
  6. "" https://notabug.org/demure/dotfiles/
  7. "" legacy repo http://github.com/demure/dotfiles
  8. """ Commands at Start """ {{{
  9. "" This one needs to be first
  10. set nocompatible " Choose no comp with legacy vi
  11. if has("syntax")
  12. syntax on " Adds vim color based on file
  13. endif
  14. "" Enable filetype settings
  15. if has("eval")
  16. filetype on
  17. filetype plugin on
  18. filetype indent on
  19. endif
  20. """ Folds Settings """ {{{
  21. if has("folding")
  22. set foldenable " Enable folds
  23. "" These next two would save which folds are open/close, as well
  24. "" as view location, but seems to force set foldmethod=indent...
  25. "au BufWinLeave ?* mkview
  26. "au BufWinEnter ?* silent loadview
  27. set foldmethod=marker
  28. set fillchars=fold:<
  29. highlight Folded ctermfg=Grey ctermbg=Black
  30. "set foldlevelstart=99 " Effectively disable auto folding
  31. """ Foldtext """ {{{
  32. "" Inspired by http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
  33. set foldtext=CustomFoldText()
  34. function! CustomFoldText()
  35. "" Process line
  36. let fs = v:foldstart
  37. let fLinePrep = substitute(getline(fs), '\t\| ', '+---', 'g')
  38. let fLine = substitute(fLinePrep, ' {\{3}', '', 'g')
  39. "" Process line count and fold precentage
  40. let fSize = 1 + v:foldend - v:foldstart
  41. let fSizeStr = " (" . fSize . " lines) "
  42. let fLineCount = line("$")
  43. let fPercent = printf(" [%.1f", (fSize*1.0)/fLineCount*100) . "%] "
  44. "" Process fold level
  45. let fLevel = " {".v:foldlevel."} "
  46. "" Process filler string
  47. let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
  48. let expansionString = repeat(".", w - strwidth(fSizeStr.fLine.fPercent.fLevel))
  49. "return fLine . expansionString . fSizeStr . foldPercent . foldLevel
  50. return fLine . fSizeStr . fPercent . fLevel
  51. endfunction
  52. """ End Foldtext """ }}}
  53. endif
  54. """ End Folds Settings """ }}}
  55. "" Stop auto comment on new line
  56. autocmd FileType * setlocal formatoptions-=cro
  57. set shortmess+=atIT " Stop messages at vim launch
  58. runtime macros/matchit.vim " Add '%' matching to if/elsif/else/end
  59. "" Mutt settings
  60. " Support Format-Flowed in email (mutt).
  61. " Because it is a good-ness? http://joeclark.org/ffaq.html
  62. autocmd FileType mail setlocal fo+=aw tw=72
  63. "" vimdiff settings
  64. if &diff
  65. set cursorline
  66. map ] ]c
  67. map [ [c
  68. colorscheme slate
  69. endif
  70. "" Disable cache for pass
  71. autocmd VimEnter
  72. \ /dev/shm/pass.?*/?*.txt
  73. \,$TMPDIR/pass.?*/?*.txt
  74. \,/tmp/pass.?*/?*.txt
  75. \ set nobackup nowritebackup noswapfile noundofile
  76. "" auto resize slits on window resize
  77. autocmd VimResized * wincmd =
  78. "" auto detech csv files
  79. if exists("did_load_csvfiletype")
  80. finish
  81. endif
  82. let did_load_csvfiletype=1
  83. augroup filetypedetect
  84. au! BufRead,BufNewFile *.csv,*.dat setfiletype csv
  85. augroup END
  86. """ End Commands at Start """ }}}
  87. """ Plugins """ {{{
  88. if $USER != 'mobile'
  89. """ Setting up Vundle """ {{{
  90. "" From http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
  91. let iCanHazVundle=1
  92. let vundle_readme=expand('~/.vim/bundle/Vundle.vim/README.md')
  93. if !filereadable(vundle_readme)
  94. echo "Installing Vundle.."
  95. echo ""
  96. silent !mkdir -p ~/.vim/bundle
  97. "" Disabled for git url
  98. silent !git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  99. let iCanHazVundle=0
  100. endif
  101. set rtp+=~/.vim/bundle/Vundle.vim/
  102. """""""call vundle#rc() ""commented out for vundle version bump change??
  103. call vundle#begin()
  104. "" Use git instead of http
  105. "let g:vundle_default_git_proto = 'git'
  106. "" Have vundle first...
  107. Plugin 'VundleVim/Vundle.vim'
  108. """ Bundles """ {{{
  109. ""Add your bundles here
  110. """ Style """ {{{
  111. Plugin 'altercation/vim-colors-solarized' " Solarized theme
  112. Plugin 'syntax-highlighting-for-tintinttpp' " Tintin++ syntax
  113. Plugin 'bling/vim-airline' " Even better than powerline/neatstatus
  114. Plugin 'nathanaelkane/vim-indent-guides' " vim-indent-guides default binding: <Leader>ig
  115. Plugin 'kien/rainbow_parentheses.vim' " Colorize parentheses and similar chars
  116. Plugin 'myusuf3/numbers.vim' " Make num ruler auto switch absolute/rel for insert/norm
  117. Plugin 'mhinz/vim-signify' " Add git diff
  118. Plugin 'mboughaba/i3config.vim' " i3 conf syntax
  119. """ End Style """ }}}
  120. """ Added Interface """ {{{
  121. Plugin 'scrooloose/nerdtree' " File browser
  122. Plugin 'bufexplorer.zip' " buffer browser
  123. Plugin 'sjl/gundo.vim' " Undo history tree
  124. "Plugin 'szw/vim-ctrlspace' " Super buffer controlness, disabled due to never using
  125. Plugin 'haya14busa/incsearch.vim' " Improved incremental searching
  126. Plugin 'spolu/dwm.vim' " dwm like split control
  127. """ End Interface """ }}}
  128. """ Added Functionality """ {{{
  129. Plugin 'tpope/vim-repeat' " Makes '.' repeat work with plugins
  130. Plugin 'scrooloose/nerdcommenter' " Make commenting easy
  131. Plugin 'YankRing.vim' " Improves copy/paste
  132. Plugin 'tpope/vim-fugitive' " git from vim
  133. Plugin 'scrooloose/syntastic' " Code syntax checker
  134. "Plugin 'SearchComplete' " Disabled due to killing UP arrow in search
  135. Plugin 'Lokaltog/vim-easymotion' " <prefix><prefix>motion
  136. Plugin 'chrisbra/csv.vim' " Good CVS file handling
  137. Plugin 'dhruvasagar/vim-table-mode' " Make easy tables
  138. "Plugin 'vim-scripts/Smart-Tabs' " Use \t for indents, and spaces elsewhere
  139. Plugin 'jamessan/vim-gnupg' " Transparent editing of gpg encrypted files
  140. Plugin 'ConradIrwin/vim-bracketed-paste' " Auto set pastemode when a bracketed paste detected. https://cirw.in/blog/bracketed-paste
  141. """ End Functionality """ }}}
  142. """ Misc """ {{{
  143. Plugin 'uguu-org/vim-matrix-screensaver' " Add unnecessary matrix screen saver
  144. Plugin 'takac/vim-hardtime' " Plugin to break bad movement habits
  145. """ End Misc """ }}}
  146. ""...All your other bundles...
  147. """ End Bundles """ }}}
  148. call vundle#end() " required
  149. if iCanHazVundle == 0
  150. echo "Installing Bundles, please ignore key map error messages"
  151. echo ""
  152. :PluginInstall
  153. endif
  154. """ End Setting Up Vundle """ }}}
  155. """ Plugin Confs """ {{{
  156. """ NERDtree config """ {{{
  157. "" Starts NERDtree if no file is give to vim at start
  158. "autocmd vimenter * if !argc() | NERDTree | endif
  159. """ End NERDtree """ }}}
  160. """ Vim Repeat Conf """ {{{
  161. "" This is to make repeat work for plugins too
  162. silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
  163. """ End Vim Repeat """ }}}
  164. """ Better Rainbow Parentheses """ {{{
  165. "" https://github.com/kien/rainbow_parentheses.vim
  166. """ Auto Rainbow """ {{{
  167. au VimEnter * RainbowParenthesesToggle
  168. au Syntax * RainbowParenthesesLoadRound
  169. au Syntax * RainbowParenthesesLoadSquare
  170. au Syntax * RainbowParenthesesLoadBraces
  171. """ End Auto """ }}}
  172. nmap <leader>[ :RainbowParenthesesToggle <CR>
  173. """ End Rainbow Parenthesis """ }}}
  174. """ YankRing Conf """ {{{
  175. "" :h yankring-tutorial
  176. nnoremap <silent> <F3> :YRShow<CR>
  177. inoremap <silent> <F3> <ESC>:YRShow<CR>
  178. map <silent> <prefix>y :YRShow<CR>
  179. let g:yankring_history_dir = '~/.vim'
  180. """ End YankRing """ }}}
  181. """ Solarized Theme """ {{{
  182. "call togglebg#map("<F6>")
  183. if has('gui_running')
  184. set background=light
  185. colorscheme solarized
  186. endif
  187. """ End Solarized """ }}}
  188. """ Gundo Conf """ {{{
  189. "" http://sjl.bitbucket.org/gundo.vim/
  190. nnoremap <F4> :GundoToggle<CR>
  191. """ End Gundo """ }}}
  192. """ Numbers.vim Conf""" {{{
  193. "" https://github.com/myusuf3/numbers.vim
  194. nnoremap <leader>n :NumbersToggle<CR>
  195. """ End Nunmbers.vim """ }}}
  196. """ Vim Indent Guides """ {{{
  197. "" https://github.com/nathanaelkane/vim-indent-guides
  198. "" <Leader>ig
  199. let g:indent_guides_auto_colors = 0
  200. "autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=236
  201. autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=240
  202. autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=244
  203. let g:indent_guides_enable_on_vim_startup = 1
  204. "let g:indent_guides_guide_size = 2
  205. let g:indent_guides_start_level = 2
  206. """ End Indent Guides """ }}}
  207. """ Airline Conf """ {{{
  208. "" Added to fix airline (forces status visibility)
  209. set laststatus=2
  210. "" Disable auto echo?
  211. let g:bufferline_echo = 0
  212. "" Remove default mode indicator
  213. set noshowmode
  214. "" Populate powerline symols
  215. let g:airline_powerline_fonts = 1
  216. """ End Airline Conf """ }}}
  217. """ Hardtime Conf """ {{{
  218. let g:hardtime_default_on = 0
  219. let g:hardtime_ignore_buffer_patterns = [ "CustomPatt[ae]rn", "NERD.*", "Task.*" ]
  220. nmap <leader>n :HardTimeToggle<CR>
  221. """ End Hardtime """ }}}
  222. """ Syntastic Conf """ {{{
  223. let g:syntastic_auto_loc_list=1
  224. """ End Syntastic """ }}}
  225. """ Vim-CtrlSpace Conf """ {{{
  226. "" https://github.com/szw/vim-ctrlspace
  227. "" Make work with airline
  228. let g:airline_exclude_preview = 1
  229. """ End Vim-CtrlSpace """ }}}
  230. """ Incsearch.vim Conf """ {{{
  231. "" https://github.com/haya14busa/incsearch.vim
  232. let g:incsearch#magic = '\v'
  233. map / <Plug>(incsearch-forward)
  234. map ? <Plug>(incsearch-backward)
  235. map g/ <Plug>(incsearch-stay)
  236. """ End Incsearch.vim """ }}}
  237. """ DWM.vim Conf """ {{{
  238. nnoremap <silent> <C-b> :call DWM_New()<CR>
  239. """ End DWM.vim Conf """ }}}
  240. """ End Plugin Confs """ }}}
  241. endif
  242. """ End Plugins """ }}}
  243. """ Theming """ {{{
  244. if has('gui_running')
  245. set background=light
  246. colorscheme solarized
  247. else
  248. colorscheme torte
  249. endif
  250. "" fix transparency
  251. hi! Normal ctermbg=NONE guibg=NONE
  252. """ End Theming """ }}}
  253. """ Options """ {{{
  254. """ Assorted """ {{{
  255. set autoread " Reload files changed outside vim
  256. set encoding=utf8 " Sets encoding View
  257. set scrolloff=3 " Show next three lines scrolling
  258. set sidescrolloff=2 " Show next two columns scrolling
  259. set ttyfast " Indicates a fast terminal connection
  260. set splitbelow " New horizontal splits are below
  261. set splitright " New vertical splits are to the right
  262. set history=1000 " Increase command/search history
  263. set confirm " Vim prompts for :q/:qa/:w issues
  264. """ End Assorted """ }}}
  265. """ HUD """ {{{
  266. set number " Adds line numbers
  267. set showcmd " Show incomplete cmds down the bottom
  268. "" Disabled for air-line
  269. "set showmode " Shows input or replace mode at bottom
  270. set ruler " Show position in bottom right
  271. """ End HUD """ }}}
  272. """ Input """ {{{
  273. set virtualedit=block,onemore " Cursor can move one past EOL, and free in Visual mode
  274. " set virtualedit=all " Allow virtual editing, all modes.
  275. set mouse=a " Enable mouse, all modes
  276. set backspace=indent,eol,start " Allow backspace in insert mode
  277. """ End Input """ }}}
  278. """ Mac kill damn bold """ {{{
  279. if has('mac')
  280. set t_Co=256 " FORCE 256 colors in vim
  281. endif
  282. """ End Mac """ }}}
  283. """ Wild Stuffs... """ {{{
  284. set wildmenu " Show list instead of just completing
  285. set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
  286. "" From http://blog.sanctum.geek.nz/lazier-tab-completion/
  287. if exists("&wildignorecase")
  288. set wildignorecase " Ignore case in file name completion
  289. endif
  290. "" From http://bitbucket.org/sjl/dotfiles/overview
  291. set wildignore+=.hg,.git,.svn " Version control
  292. set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
  293. set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
  294. set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
  295. set wildignore+=*.spl " compiled spelling word lists
  296. set wildignore+=*.sw? " Vim swap files
  297. set wildignore+=*.DS_Store " OSX bullshit
  298. set wildignore+=*.luac " Lua byte code
  299. set wildignore+=migrations " Django migrations
  300. set wildignore+=*.pyc " Python byte code
  301. set wildignore+=*.orig " Merge resolution files
  302. "" Clojure/Leiningen
  303. set wildignore+=classes
  304. set wildignore+=lib
  305. """ End Wild """ }}}
  306. """ Show Hidden Chars """ {{{
  307. set list " Shows certain hidden chars
  308. set listchars=eol:¬,tab:▶-,trail:~,extends:>,precedes:<,nbsp:·
  309. hi NonText ctermfg=darkgray " Makes trailing darkgray
  310. hi SpecialKey ctermfg=darkgray " Makes Leading darkgray
  311. """ End Hidden Chars """ }}}
  312. """ Spelling """ {{{
  313. set spell " Spelling hilight on
  314. " highlight SpellBad cterm=underline ctermfg=red
  315. hi SpellBad cterm=underline ctermbg=NONE
  316. hi SpellCap cterm=underline ctermbg=NONE
  317. """ End Spelling """ }}}
  318. """ Tab Windows """ {{{
  319. set hidden " Hides buffers, instead of closing, or forcing save
  320. set showtabline=2 " shows the tab bar at all times
  321. set tabpagemax=100 " max num of tabs to open on startup
  322. hi TabLineSel ctermbg=Yellow " Current Tab
  323. hi TabLine ctermfg=Grey ctermbg=DarkGrey " Other Tabs
  324. hi TabLineFill ctermfg=Black " Rest of line
  325. hi Title ctermfg=DarkBlue ctermbg=None " Windows in Tab
  326. """ End Tab Windows """ }}}
  327. """ Tab Key Settings """ {{{
  328. "" prefer tabs now...
  329. set expandtab "" use spaces, not tabs
  330. set tabstop=4 " Set Tab length
  331. set shiftwidth=4 " Affects when you press >>, << or ==. And auto indent.
  332. set shiftround " Uses multiple of shiftwidth when indenting with '<' and '>'
  333. set softtabstop=4 " With space indenting, lets vim delete multiple spaces at once
  334. "" disabled per https://stackoverflow.com/questions/234564/tab-key-4-spaces-and-auto-indent-after-curly-braces-in-vim
  335. " set smarttab " Insert Tabs at ^ per shiftwidth, not tabstop
  336. set autoindent " Always set auto indenting on
  337. set copyindent " Copy prior indentation on autoindent
  338. """ End Tab Key """ }}}
  339. """ Searching """ {{{
  340. " Use real regex search
  341. nnoremap / /\v
  342. vnoremap / /\vi
  343. set hlsearch " Highlight matches
  344. set incsearch " Incremental searching
  345. set ignorecase " Searches are case insensitive...
  346. "" Disabled as was annoying with command completion
  347. "set smartcase " ...unless contains oneplus Cap letter
  348. set showmatch " Show matching brackets/parenthesis
  349. set gdefault " Applies substitutions globally on lines. Append 'g' to invert back.
  350. set synmaxcol=800 " Don't highlight lines longer than 800 chars
  351. set wrapscan " Scan wraps around the file
  352. """ End Searching """ }}}
  353. """ Backup Settings """ {{{
  354. """ Dir Validation """ {{{
  355. if !isdirectory(expand("~/.vim/back/"))
  356. call mkdir(expand("~/.vim/back/"), "p")
  357. endif
  358. if !isdirectory(expand("~/.vim/swap/"))
  359. call mkdir(expand("~/.vim/swap/"), "p")
  360. endif
  361. if !isdirectory(expand("~/.vim/undo/"))
  362. call mkdir(expand("~/.vim/undo/"), "p")
  363. endif
  364. """ End Dir """ }}}
  365. set backup " Enable backups
  366. set undofile " Enable undo file
  367. set undoreload=10000
  368. set backupdir=~/.vim/back// " back files, // for full path
  369. set directory=~/.vim/swap// " swap files, // for full path
  370. set undodir=~/.vim/undo// " undo files, // for full path
  371. """ End Backup Settings """ }}}
  372. """ Timeout Settings """ {{{
  373. set timeout " :mapping time out
  374. set timeoutlen=1000 " :mapping time out length
  375. set ttimeout " Key code time out
  376. set ttimeoutlen=50 " key code time out length
  377. """ End Timeout """ }}}
  378. """ End Options """ }}}
  379. """ Aliases """ {{{
  380. command! BI BundleInstall
  381. """ End Aliases """ }}}
  382. """ Functions """ {{{
  383. """ DiffSaved """ {{{
  384. "" To compare current vs saved version
  385. "" http://vim.wikia.com/wiki/Diff_current_buffer_and_the_original_file
  386. "" To get out of diff view you can use the :diffoff command.
  387. function! s:DiffWithSaved()
  388. let filetype=&ft
  389. diffthis
  390. vnew | r # | normal! 1Gdd
  391. diffthis
  392. exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  393. endfunction
  394. com! DiffSaved call s:DiffWithSaved()
  395. """End DiffSaved """ }}}
  396. """ HighlightRepeats """ {{{
  397. "" from https://stackoverflow.com/questions/1268032/how-can-i-mark-highlight-duplicate-lines-in-vi-editor
  398. function! HighlightRepeats() range
  399. let lineCounts = {}
  400. let lineNum = a:firstline
  401. while lineNum <= a:lastline
  402. let lineText = getline(lineNum)
  403. if lineText != ""
  404. let lineCounts[lineText] = (has_key(lineCounts, lineText) ? lineCounts[lineText] : 0) + 1
  405. endif
  406. let lineNum = lineNum + 1
  407. endwhile
  408. exe 'syn clear Repeat'
  409. for lineText in keys(lineCounts)
  410. if lineCounts[lineText] >= 2
  411. exe 'syn match Repeat "^' . escape(lineText, '".\^$*[]') . '$"'
  412. endif
  413. endfor
  414. endfunction
  415. command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats()<F29>
  416. """ End HighlightRepeats """ }}}
  417. """ End Functions """ }}}
  418. """ Key Bindings """ {{{
  419. let mapleader="," " Change the mapleader from '\' to ','
  420. map <leader>/ :noh<return> " <leader>/ will clear search hilights!
  421. """ Quickly edit/reload the vimrc file """ {{{
  422. "" maps the ,ev and ,sv keys to edit/reload .vimrc.
  423. nmap <silent> <leader>ev :tabedit $MYVIMRC<CR>
  424. nmap <silent> <leader>sv :so $MYVIMRC<CR>
  425. """ End reload """ }}}
  426. """ Paste Toggle, for stopping formating of pastes """ {{{
  427. nnoremap <F2> :set invpaste paste?<CR>
  428. set pastetoggle=<F2>
  429. nmap <leader>p :set invpaste paste?<CR>
  430. """ End Paste Toggle """ }}}
  431. """ Vim Tab Window Keysbindings """ {{{
  432. " nnoremap <C-Left> :tabprevious<CR>
  433. " nnoremap <C-Right> :tabnext<CR>
  434. " nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
  435. " nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR>
  436. """ End Tab Window Keys """ }}}
  437. """ Navigate Splits """ {{{
  438. "" uses ',' key first
  439. map <leader>h :wincmd h<CR>
  440. map <leader>j :wincmd j<CR>
  441. map <leader>k :wincmd k<CR>
  442. map <leader>l :wincmd l<CR>
  443. map <leader> <Left> :wincmd h<CR>
  444. map <leader> <Down> :wincmd j<CR>
  445. map <leader> <Up> :wincmd k<CR>
  446. map <leader> <Right> :wincmd l<CR>
  447. """ End Navigate Splits """ }}}
  448. """ Toggle colorcolumn """ {{{
  449. highlight ColorColumn ctermbg=Brown
  450. function! g:ToggleColorColumn()
  451. if &colorcolumn != ''
  452. setlocal colorcolumn&
  453. else
  454. setlocal colorcolumn=77
  455. endif
  456. endfunction
  457. nnoremap <silent> <leader>L :call g:ToggleColorColumn()<CR>
  458. """ End Toggle colorcolumn """ }}}
  459. """ Cross Hairs """ {{{
  460. hi CursorLine cterm=NONE ctermbg=brown ctermfg=white guibg=darkred guifg=white
  461. hi CursorColumn cterm=NONE ctermbg=brown ctermfg=white guibg=darkred guifg=white
  462. nnoremap <Leader>+ :set cursorline! cursorcolumn!<CR>
  463. """ End Cross Hair """ }}}
  464. """ DiffOrig """ {{{
  465. "command DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe "norm! ".g:diffline."G" | wincmd p | diffthis | wincmd p
  466. command! DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe 'norm! '.g:diffline.'G' | wincmd p | diffthis | wincmd p
  467. nnoremap <Leader>do :DiffOrig<cr>
  468. nnoremap <leader>dc :q<cr>:diffoff<cr>:exe "norm! ".g:diffline."G"<cr>
  469. """ End DiffOrig """ }}}
  470. """ Sudo Save Edit """ {{{
  471. "" Use :W to sudo save, may mess with permissions
  472. command! WW w !sudo tee % > /dev/null
  473. """ End Sudo Save """ }}}
  474. """ Typo Commands """ {{{
  475. "" http://blog.sanctum.geek.nz/vim-command-typos/
  476. if has("user_commands")
  477. command! -bang -nargs=? -complete=file E e<bang> <args>
  478. command! -bang -nargs=? -complete=file W w<bang> <args>
  479. command! -bang -nargs=? -complete=file Wq wq<bang> <args>
  480. command! -bang -nargs=? -complete=file WQ wq<bang> <args>
  481. command! -bang Wa wa<bang>
  482. command! -bang WA wa<bang>
  483. command! -bang Q q<bang>
  484. command! -bang QA qa<bang>
  485. command! -bang Qa qa<bang>
  486. endif
  487. """ End Typo """ }}}
  488. """ End Key Bindings """ }}}
  489. """ Notes To Self """ {{{
  490. "" Consider:
  491. " set foldopen=
  492. """ End Notes """ }}}