Advertisement
atimholt

My vimrc 2011-11-26

Nov 26th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.64 KB | None | 0 0
  1. " Tim Holt's vimrc file
  2. " Created probably in 2010, Idunno.
  3. " modified extensively continously since then.
  4. "
  5. " This file is full of ‘*’ command ‘links’ __in_this_format.
  6. "
  7. " Free to use for anyone
  8.  
  9. "│-v-1 │ To-Do's
  10. "└─────┴─────────
  11. " (not actually settings, just settings todo's)
  12. " TODO Look into the 'tabline' setting
  13. " TODO When numbers are off, change window width.
  14.  
  15. "│-v-1 │ “precedence” necessaries.
  16. "└─────┴───────────────────────────
  17. "For virtually everything, and sanity in general:
  18. set nocp
  19. filetype plugin on
  20.  
  21. "For that which __requires_utf_8:
  22. set encoding=utf8
  23.  
  24. " Note: Make sure to link here from _every_ line that has a prerequisite,
  25. " and from every location in this file where the prerequisite would more
  26. " naturally be categorized.
  27.  
  28.  
  29. "│-v-1 │ Plug-in Settings
  30. "└─┬───┴─┬────────────────
  31. "│-v-2 │ plug-in manager
  32. "└─────┴─────────────────
  33. " pathogen startup stuff
  34. filetype off
  35. call pathogen#infect()
  36. call pathogen#helptags()
  37. filetype plugin on
  38.  
  39.  
  40. "│-v-2 │ Individual plug-ins
  41. "└─┬───┴─┬───────────────────
  42. "│-v-3 │ Gundo Settings
  43. "└─────┴────────────────
  44. nnoremap <silent> <leader>u :GundoToggle<cr>
  45. let g:gundo_help=1
  46. let g:gundo_right=0
  47. let g:gundo_preview_bottom=0
  48.  
  49. " Mappings (@__gundo_mappings):
  50. " toggle Gundo
  51.  
  52. "│-v-3 │ vimwiki Settings
  53. "└─────┴──────────────────
  54. let g:vimwiki_camel_case = 0
  55.  
  56. let wiki_1 = {}
  57. let wiki_1.path = '~/Dropbox/Vim/vimwiki/'
  58. let wiki_1.nested_syntaxes = {'c++': 'cpp', 'asm': 'asm', 'sh': 'sh'}
  59.  
  60. let wiki_2 = {}
  61. let wiki_2.path = '~/Dropbox/timwrite/vimfriendly/Inhuman_Universe/wiki/'
  62.  
  63. let g:vimwiki_list = [wiki_1, wiki_2]
  64.  
  65. "│-v-3 │ Full-Screen Mode Settings
  66. "└─────┴───────────────────────────
  67. " Mappings (@__full_screen_mappings):
  68. function! ToggleFullScreen()
  69. if has('win32')
  70. :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)
  71. endif
  72. endfunction
  73.  
  74. "│-v-3 │ 'a' settings
  75. "└─────┴──────────────
  76. " Mappings (@__a_mappings):
  77.  
  78. "│-v-3 │ Rainbow Parentheses Settings
  79. "└─────┴──────────────────────────────
  80. " (Steve Losh's modified version, cleaned up and jazz)
  81.  
  82. " Mappings (@__rainbow_parentheses_mappings):
  83. autocmd BufEnter * RainbowParenthesesLoadRound
  84. autocmd BufEnter * RainbowParenthesesLoadBraces
  85.  
  86. "│-v-1 │ Set-up
  87. "└─┬───┴─┬──────
  88. "│-v-2 │ Behavior
  89. "└─┬───┴─┬────────
  90. "│-v-3 │ “meta” (settings settings)
  91. "└─────┴────────────────────────────
  92.  
  93. " Quick settings access
  94. " TODO: maybe make this a function
  95. nnoremap <silent> <F2> :tabedit $MYVIMRC<cr>:lcd $HOME<cr>:vs ~/Dropbox/Vim/vimrc.vim<cr>
  96.  
  97.  
  98. " Reload vimrc when saved
  99. au! BufWritePost $MYVIMRC source $MYVIMRC
  100.  
  101. " Doesn't work, because MyRefreshFullScreen doesn't work.
  102. " TODO: evaluate this thing.
  103. function! MyRefreshVimrc()
  104. :source $MYVIMRC
  105. :call MyRefreshFullScreen()
  106. endfunction
  107.  
  108. "│-v-3 │ Tweakings/Feature Settings
  109. "└─┬───┴─┬──────────────────────────
  110. "│-v-4 │ Intended/Built-In Settings
  111. "└─┬───┴─┬──────────────────────────
  112. "│-v-5 │ Editing Settings
  113. "└─────┴──────────────────
  114. set expandtab
  115. set shiftwidth=2
  116. set softtabstop=2
  117. set tabstop=2
  118. set backspace=indent,eol,start
  119. set ruler
  120. :syntax enable
  121. :set cindent
  122.  
  123. :set switchbuf=useopen,usetab,newtab
  124.  
  125. " Allows the closing of buffers without saving.
  126. set hidden
  127.  
  128. " allows cursor position past true end of line
  129. set virtualedit=all
  130.  
  131. " Whether jumping to another line (like with "G") goes to the start
  132. " of the line, or tries to stay in the same column.
  133. set nostartofline
  134.  
  135. "│-v-5 │ Spelling
  136. "└─────┴──────────
  137. set spelllang=en_us,es,eo
  138.  
  139. "│-v-5 │ Status Line
  140. "└─────┴─────────────
  141. ":set statusline=%F%m%r%h%w\ (%{&ff})\ typ:%Y\ ASCII=\%04.8b\ HEX=\%04.4B\ %l,%v %p%%\ LEN=%L
  142. "set statusline=%<[%02n]\ %F%(\ %m%h%w%y%r%)\ %a%=\ %8l,%c%V/%L\ (%P)\ [%08O:%02B]
  143. set statusline=%<[%02n]\ %F%(\ %m%h%w%y%r%)\ %a%=\ %8l,%c%V/%L\ (%P)\ [%02B]
  144.  
  145. set laststatus=2
  146. " “The value of this option influences when the
  147. " last window will have a status line…”
  148.  
  149. "│-v-5 │ Folds
  150. "└─────┴──────────
  151. :set foldmethod=marker
  152. :set foldmarker=-v-,-^-
  153.  
  154. "│-v-5 │ WildMenu
  155. "└─────┴──────────
  156. set wildmode=longest,list,full
  157. :set wildmenu
  158.  
  159. "│-v-5 │ persistent undo
  160. "└─────┴─────────────────
  161. set undofile
  162.  
  163. "│-v-5 │ search settings
  164. "└─────┴─────────────────
  165. set ignorecase
  166. set smartcase
  167. set gdefault
  168. set incsearch
  169. set showmatch
  170. set hlsearch
  171. " Mappings (@__search_mappings):
  172. " Switch off search highlighting.
  173.  
  174. "│-v-5 │ netrw settings
  175. "└─────┴────────────────
  176. let g:netrw_liststyle=3
  177.  
  178. "│-v-5 │ External Shell Settings
  179. "└─────┴─────────────────────────
  180. " __requires_utf_8:
  181. if has('win32')
  182. set shell=powershell.exe
  183. set shellcmdflag=-c
  184. set shellpipe=|
  185. set shellredir=>
  186. endif
  187.  
  188. "│-v-4 │ Customized behavior
  189. "└─┬───┴─┬───────────────────
  190. "│-v-5 │ (function) Toggle Spell Checking.
  191. "└─────┴───────────────────────────────────
  192. " (mapping @__spell_check_mapping)
  193. let g:timspellmode = 0
  194. function! g:ToggleSpellMode()
  195. if g:timspellmode == 0
  196. let g:timspellmode = 1
  197. set spell
  198. else
  199. let g:timspellmode = 0
  200. set nospell
  201. endif
  202. endfunction
  203. "│-v-5 │ (function) Box character (turburul) hax
  204. "└─────┴─────────────────────────────────────────
  205. " This:
  206. " r----v-,
  207. " | | |
  208. " >----+-<
  209. " | | |
  210. " >————+—<
  211. " | | |
  212. " L----^-’
  213. "
  214. " Becomes This:
  215. " ┌────┬─┐
  216. " │ │ │
  217. " ├────┼─┤
  218. " │ │ │
  219. " ├────┼─┤
  220. " │ │ │
  221. " └────┴─┘
  222. " (mapping @__box_characters_mapping)
  223. function! g:BoxCharacters()
  224. :s'r'┌'e
  225. gv
  226. :s','┐'e
  227. gv
  228. :s'’'┘'e
  229. gv
  230. :s/'/┘/e
  231. gv
  232. :s'L'└'e
  233.  
  234. gv
  235. :s'|'│'e
  236. gv
  237. :s'-'─'e
  238. gv
  239. :s'—'─'e
  240. gv
  241. :s'+'┼'e
  242.  
  243. gv
  244. :s'\^'┴'e
  245. gv
  246. :s'>'├'e
  247. gv
  248. :s'v'┬'e
  249. gv
  250. :s'T'┬'e
  251. gv
  252. :s'<'┤'e
  253. endfunction
  254. "│-v-5 │ (functions) Multi-Window automatic stuff
  255. "└─────┴──────────────────────────────────────────
  256. " These settings rely heavily on the specific ways I personally use Vim.
  257. " (auto-commands @__multi_window_autocmds)
  258.  
  259. function! TimWinLeaveWithGundo()
  260. if !GundoInTab() && g:timdisplaymode == 'code'
  261. :vertical resize
  262. :set nowrap
  263. :set norelativenumber
  264. :set nonumber
  265. endif
  266. endfunction
  267.  
  268. function! TimWinEnterWithGundo()
  269. if !GundoInTab() && g:timdisplaymode == 'code'
  270. if g:tim_number_mode == 0
  271. :vertical resize 81
  272. else
  273. :vertical resize 85
  274. endif
  275. :set wrap
  276. :call g:TimDisplayNumbers()
  277. endif
  278. endfunction
  279.  
  280. function! GundoInTab()
  281. let s:current_tabpagebuflist = tabpagebuflist()
  282. for i in s:current_tabpagebuflist
  283. if bufname(i) == "__Gundo__"
  284. return 1
  285. endif
  286. endfor
  287. return 0
  288. endfunction
  289.  
  290. "│-v-5 │ (functions) Line-number Mode switching
  291. "└─────┴────────────────────────────────────────
  292. " (mappings @__line_number_modes_mappings)
  293.  
  294. let g:tim_number_mode = 1
  295.  
  296. function! g:ToggleNuMode(...)
  297. if a:0
  298. let g:tim_number_mode = a:1 " TODO: use this somewhere.
  299. else
  300. let g:tim_number_mode += 1
  301. endif
  302.  
  303. if g:tim_number_mode > 2
  304. let g:tim_number_mode = 0
  305. endif
  306. if g:tim_number_mode < 0
  307. let g:tim_number_mode = 2
  308. endif
  309.  
  310. call g:TimDisplayNumbers()
  311. endfunc
  312.  
  313. function! g:TimDisplayNumbers()
  314. if(g:tim_number_mode == 1)
  315. if g:timdisplaymode == 'code'
  316. :vertical resize 85
  317. endif
  318. set number
  319. elseif(g:tim_number_mode == 2)
  320. if g:timdisplaymode == 'code'
  321. :vertical resize 85
  322. endif
  323. set relativenumber
  324. else
  325. if g:timdisplaymode == 'code'
  326. :vertical resize 81
  327. endif
  328. set nonumber
  329. set norelativenumber
  330. endif
  331. endfunc
  332.  
  333. "│-v-3 │ Mappings, Auto-Commands & Abbreviations.
  334. "└─┬───┴─┬────────────────────────────────────────
  335. "│-v-4 │ Mappings
  336. "└─┬───┴─┬────────
  337. "│-v-5 │ Leader Key Settings
  338. "└─────┴─────────────────────
  339. let mapleader = ","
  340. " doesn't work?:
  341. noremap <C-,> <leader>
  342.  
  343. "│-v-5 │ navigation remaps
  344. "└─────┴─────────────────────
  345. nnoremap <tab> %
  346. vnoremap <tab> %
  347.  
  348. nnoremap <silent> <leader>t :tabs<cr>
  349. nnoremap <silent> <leader>b :ls<cr>
  350.  
  351. nnoremap j gj
  352. nnoremap k gk
  353.  
  354. nnoremap <leader>h <C-W>h
  355. nnoremap <leader>l <C-W>l
  356. nnoremap <leader>j <C-W>j
  357. nnoremap <leader>k <C-W>k
  358. " for use with the numeric version:
  359. nnoremap <leader>W <C-W><C-W>
  360.  
  361. "│-v-5 │ Normal-Mode alternative access.
  362. "└─────┴─────────────────────────────────
  363. " TODO: Change the windows mapping to changing caps lock to esc.
  364. if has('win32')
  365. inoremap hh <esc>
  366. cnoremap hh <esc>
  367. endif
  368.  
  369. "│-v-5 │ toggle showing of invisible characters
  370. "└─────┴────────────────────────────────────────
  371. nnoremap <silent> <leader>i :set list!<cr>
  372.  
  373. "│-v-5 │ OS clip-board easy-integration.
  374. "└─────┴─────────────────────────────────
  375. nnoremap <leader>y "+y
  376. vnoremap <leader>y "+y
  377.  
  378. nnoremap <leader>Y "+Y
  379. vnoremap <leader>Y "+Y
  380.  
  381. nnoremap <leader>p "+p
  382. vnoremap <leader>p "+p
  383.  
  384. nnoremap <leader>P "+P
  385. vnoremap <leader>P "+P
  386.  
  387. "│-v-5 │ Jump to file shortcut
  388. "└─────┴───────────────────────
  389. nnoremap <silent> <leader>f <c-w>gf
  390.  
  391. "│-v-5 │ File-name completion shortcut
  392. "└─────┴───────────────────────────────
  393. inoremap <c-f> <c-x><c-f>
  394.  
  395. "│-v-5 │ __search_mappings:
  396. "└─────┴────────────────────
  397. " Switch off search highlighting.
  398. nnoremap <silent> <leader><space> :noh<cr>
  399.  
  400. "│-v-5 │ Quick window-width reset
  401. "└─────┴──────────────────────────
  402. nnoremap <leader><Bar> :vertical resize 85<cr>
  403.  
  404. "│-v-5 │ Generate Tag files
  405. "└─────┴────────────────────
  406. "map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
  407. map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q *.h *.cpp<CR>
  408.  
  409. "│-v-5 │ mappings to customized-behavior & functions.
  410. "└─┬───┴─┬──────────────────────────────────────────
  411. "│-v-6 │ __spell_check_mapping:
  412. "└─────┴────────────────────────
  413. nnoremap <F5> :call g:ToggleSpellMode()<cr>
  414.  
  415. "│-v-6 │ __box_characters_mapping:
  416. "└─────┴───────────────────────────
  417. vnoremap <silent> <leader>b :call g:BoxCharacters()<cr>
  418.  
  419. "│-v-6 │ __line_number_modes_mappings:
  420. "└─────┴───────────────────────────────
  421. " TODO: use <leader>n for cycle, <leader>N[mnemonic] for absolute.
  422. nnoremap <silent> <leader>n :call g:ToggleNuMode()<cr>
  423. nnoremap <silent> 3<leader>n :call g:ToggleNuMode(0)<cr>
  424. nnoremap <silent> 1<leader>n :call g:ToggleNuMode(1)<cr>
  425. nnoremap <silent> 2<leader>n :call g:ToggleNuMode(2)<cr>
  426. nnoremap <silent> <leader>N :call g:ToggleNuMode()<cr>:call g:ToggleNuMode()<cr>
  427. "│-v-6 │ __display_mode_mappings:
  428. "└─────┴──────────────────────────
  429. nnoremap <silent> <leader>d :call ToggleDisplayMode()<cr>
  430.  
  431. "│-v-5 │ mappings to Plug-ins
  432. "└─┬───┴─┬────────────────────
  433. "│-v-6 │ __gundo_mappings:
  434. "└─────┴───────────────────
  435. " toggle Gundo:
  436. nnoremap <silent> <leader>u :GundoToggle<cr>
  437.  
  438. "│-v-6 │ __full_screen_mappings:
  439. "└─────┴─────────────────────────
  440. map <silent> <F11> <Esc>:call ToggleFullScreen()<CR>
  441.  
  442. "│-v-6 │ __a_mappings:
  443. "└─────┴───────────────
  444. nnoremap <silent> <leader>a :AV<cr>
  445. nnoremap <silent> <leader>s :AV<cr>
  446. nnoremap <silent> <leader>v :vs<cr>
  447.  
  448. "│-v-6 │ __rainbow_parentheses_mappings:
  449. "└─────┴─────────────────────────────────
  450. nnoremap <silent> <leader>, :RainbowParenthesesToggle<cr>
  451.  
  452. "│-v-4 │ Auto-commands
  453. "└─┬───┴─┬─────────────
  454. "│-v-5 │ Independent auto-commands
  455. "└─────┴───────────────────────────
  456. autocmd BufRead,BufNewFile *.txtfmt setfiletype txtfmt
  457. "│-v-5 │ function auto-commands
  458. "└─┬───┴─┬──────────────────────
  459. "│-v-6 │ __multi_window_autocmds
  460. "└─────┴─────────────────────────
  461. autocmd WinLeave * :call TimWinLeaveWithGundo()
  462. autocmd WinEnter * :call TimWinEnterWithGundo()
  463.  
  464.  
  465. "│-v-4 │ Abbreviations
  466. "└─┬───┴─┬─────────────
  467. "│-v-5 │ Shortcuts
  468. "└─────┴───────────
  469. ab ?! ‽
  470. ab !? ‽
  471.  
  472. :ab ,.0 ⁰
  473. :ab ,.1 ¹
  474. :ab ,.2 ²
  475. :ab ,.3 ³
  476. :ab ,.4 ⁴
  477. :ab ,.5 ⁵
  478. :ab ,.6 ⁶
  479. :ab ,.7 ⁷
  480. :ab ,.8 ⁸
  481. :ab ,.9 ⁹
  482.  
  483. "│-v-5 │ Corrections
  484. "└─────┴─────────────
  485. "│-v-2 │ Appearance
  486. "└─┬───┴─┬──────────
  487. "│-v-3 │ Built-in Settings
  488. "└─┬───┴─┬─────────────────
  489. "│-v-4 │ GUI Options (default is "egmrLtT")
  490. "└─────┴────────────────────────────────────
  491. :set guioptions=
  492. " Note that fullscreen plugin doesn't work well with anything but null
  493. " (or similar).
  494.  
  495. "│-v-4 │ Color scheme
  496. "└─────┴──────────────
  497. set t_Co=256
  498.  
  499. " Not sure if this one's actually necessary.
  500. :set background=dark
  501.  
  502. " Some favorite color schemes. Just leave your choice the only
  503. " un-commented one. (and make sure you actually have the colorscheme,
  504. " and it's compatible!)
  505.  
  506. :colorscheme timbat
  507. ":colorscheme timatrix " I've put a lot of my own adjustments into this one.
  508. ":colorscheme pyte
  509.  
  510. "│-v-4 │ Current-Row-Column highlighting
  511. "└─────┴─────────────────────────────────
  512. autocmd WinLeave * set nocursorline nocursorcolumn
  513. autocmd WinEnter * set cursorline cursorcolumn
  514. set cursorline cursorcolumn
  515.  
  516. "│-v-4 │ Window Width & Such
  517. "└─────┴─────────────────────
  518. set winminwidth=12
  519.  
  520. "│-v-4 │ Invisible characters depiction.
  521. "└─────┴─────────────────────────────────
  522. " __requires_utf_8:
  523. set listchars=tab:▸\ ,eol:¬
  524.  
  525. "│-v-4 │ Miscellaneous
  526. "└─────┴───────────────
  527. set showcmd
  528.  
  529. "│-v-3 │ Custom Functions
  530. "└─┬───┴─┬────────────────
  531. "│-v-4 │ Display Mode Stuff
  532. "└─────┴────────────────────
  533. " Mappings (@__display_mode_mappings):
  534. function! g:ApplyDisplayMode(...)
  535. if a:0
  536. let g:timdisplaymode = a:1
  537. endif
  538.  
  539. if g:timdisplaymode == 'code'
  540. set cursorcolumn
  541. set nospell " -v-
  542.  
  543. if &filetype=='vimwiki'
  544. setlocal linebreak
  545. else
  546. set nolinebreak
  547. endif
  548.  
  549. if has('win32')
  550. :set guifont=consolas:h11
  551. else
  552. set guifont=Consolas\ 12
  553. endif
  554.  
  555. colorscheme timbat
  556. set display-=lastline
  557. let &showbreak = ''
  558. set foldmarker=-v-,-^-
  559. au WinEnter * set cursorcolumn
  560. " -^-
  561. elseif g:timdisplaymode == 'composition'
  562. set nocursorcolumn
  563. setlocal spell " -v-
  564. inoremap <C-BS> <Esc>b1z=wi
  565.  
  566. setlocal linebreak
  567.  
  568. if has('win32')
  569. :set guifont=consolas:h16
  570. else
  571. setlocal guifont=Consolas\ 16
  572. endif
  573.  
  574. colorscheme timatrix
  575. setlocal display+=lastline
  576. let &showbreak = ' '
  577. " setlocal foldmarker={{{,}}}
  578. set foldmarker=-v-,-^-
  579. au BufEnter * set nocursorcolumn
  580. endif " -^-
  581. endfunction
  582.  
  583. let g:timdisplaymode = ''
  584. call g:ApplyDisplayMode('code')
  585.  
  586. function! ToggleDisplayMode()
  587. if g:timdisplaymode == 'code'
  588. let g:timdisplaymode = 'composition'
  589. else
  590. let g:timdisplaymode = 'code'
  591. endif
  592.  
  593. call g:ApplyDisplayMode()
  594. endfunction
  595.  
  596.  
  597.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement