Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.89 KB | None | 0 0
  1. filetype off
  2.  
  3.  
  4. set nocompatible
  5. filetype plugin indent on
  6. filetype on
  7. syntax on
  8.  
  9.  
  10. let &t_SI = "\033]12;orange\007"
  11. let &t_EI = "\033]12;white\007"
  12. autocmd VimLeave * :!echo -ne "\033]12;white\007"
  13.  
  14. autocmd!
  15. if &term =~ 'xterm'
  16. set t_kd=<Down>
  17. set t_ku=<Up>
  18. set t_kr=<Right>
  19. set t_kl=<Left>
  20. if $COLORTERM == 'gnome-terminal' || $COLORTERM == 'xfce4-terminal'
  21. set term=linux
  22. set t_RV=
  23. set t_Co=256
  24. if has("autocmd")
  25. au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
  26. au InsertEnter,InsertChange *
  27. \ if v:insertmode == 'i' |
  28. \ silent execute '!echo -ne "\e[6 q"' | redraw! |
  29. \ elseif v:insertmode == 'r' |
  30. \ silent execute '!echo -ne "\e[4 q"' | redraw! |
  31. \ endif
  32. au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
  33. endif
  34. elseif $COLORTERM == ''
  35. execute 'set t_kb=' . nr2char(8)
  36. fixdel
  37. endif
  38. endif
  39.  
  40. nmap <ESC>oA <ESC>k
  41. nmap <ESC>oB <ESC>j
  42. nmap <ESC>oC <ESC>l
  43. nmap <ESC>oD <ESC>h
  44.  
  45.  
  46. if has("unix")
  47. let s:uname = system("uname -s")
  48. if s:uname == "Darwin"
  49. let &t_SI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
  50. let &t_EI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\""
  51. endif
  52. endif
  53.  
  54.  
  55. :au FocusGained * call getchar(0)
  56.  
  57. set history=5000
  58. set noundofile
  59. set undolevels=5000
  60. set undodir=~/.vim/undodir
  61.  
  62.  
  63.  
  64.  
  65.  
  66. set viminfo=!,/100,'100,r/mnt/zip,r/mnt/floppy,f1,h,\"100,:1000,n$HOME/.vim/.viminfo
  67.  
  68.  
  69. set complete=.,w,b,u,U,i
  70. if has("unix")
  71. set dictionary=/usr/share/dict/words
  72. set complete+=k
  73. endif
  74.  
  75.  
  76. colorscheme darkblue
  77. set completeopt=menu
  78. set wildmenu
  79. set wildmode=list:longest,full
  80. set wildignore+=*/.vim/undodir/*,.git/*,*/*~,_*
  81. set shortmess+=r
  82. set showmode
  83. set showcmd
  84. set mouse=a
  85. set modeline
  86. set nowrap
  87. set ruler
  88. set nosol
  89. set nu
  90. set scrolloff=9
  91. set novisualbell
  92. if exists("+autochdir")
  93. set autochdir
  94. endif
  95.  
  96. set lazyredraw
  97. set hidden
  98. set nojoinspaces
  99. set shiftwidth=2
  100. set shiftround
  101. set autoindent
  102. set splitright
  103.  
  104. set hls
  105. set formatoptions-=ta
  106. set textwidth=79
  107. set cpoptions+=ly
  108. if has('cryptv')
  109. set cryptmethod=blowfish " blowfish
  110. endif
  111.  
  112. nmap <leader>l :set list!<CR>
  113.  
  114. if has("unix")
  115. set listchars+=tab:▸\ ,eol:¬,trail:·
  116. endif
  117.  
  118.  
  119. set comments+=b:\"
  120. set comments+=n::
  121.  
  122. augroup filetype
  123. autocmd BufNewFile * setlocal filetype=txt
  124. autocmd BufEnter * if &filetype == "" | setlocal filetype=txt | endif
  125. autocmd VimEnter *popsci.com* set filetype=markdown
  126. autocmd VimEnter *popsci.com* :call Bupname()
  127. augroup END
  128.  
  129. fun! Bupname()
  130. let l:curfile = "$HOME/.vim/backups/" . expand("%:t:") . "_BACKUP.html"
  131. silent execute 'write' l:curfile
  132. endfun
  133.  
  134. autocmd FileType css set smartindent
  135. autocmd FileType txt if &statusline !~ "WC: " | setlocal statusline+=\ \ WC:\ %{WordCount()}\
  136.  
  137. autocmd BufEnter * if &filetype == "help" | let &statusline = mystatusline | endif
  138. autocmd BufWritePost vimrc source $MYVIMRC | source $MYGVIMRC
  139. autocmd BufWritePost .vimrc source $MYVIMRC | source $MYGVIMRC
  140.  
  141. autocmd FileType html set formatoptions+=tl
  142. autocmd FileType mail set formatoptions+=a
  143.  
  144. au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  145.  
  146. autocmd FileType vim set commentstring=\"%s
  147.  
  148. augroup textobj_quote
  149. autocmd!
  150. autocmd FileType markdown call textobj#quote#init() | call textobj#sentence#init()
  151. autocmd FileType text call textobj#quote#init({'educate': 0}) | call textobj#sentence#init()
  152. augroup END
  153.  
  154. augroup textobj_sentence
  155. autocmd!
  156. autocmd FileType markdown call textobj#sentence#init()
  157. autocmd FileType textile call textobj#sentence#init()
  158. autocmd FileType text call textobj#sentence#init()
  159. augroup END
  160.  
  161.  
  162.  
  163. set ignorecase
  164. set smartcase
  165. set incsearch
  166. set whichwrap=h,l,~,[,],<,>
  167.  
  168.  
  169. set matchpairs+=<:>
  170. set matchpairs+=':'
  171. set matchpairs+=":"
  172.  
  173.  
  174.  
  175. let loaded_matchparen = 0
  176.  
  177. nnoremap <F1> :help<Space>
  178. vmap <F1> <C-C><F1>
  179. omap <F1> <C-C><F1>
  180. map! <F1> <C-C><F1>
  181.  
  182. nnoremap Q gw/^>*\s*$<Enter>
  183. vnoremap Q gq
  184.  
  185. vnoremap <C-T> >
  186. vnoremap <C-D> <LT>
  187. vnoremap <Tab> <C-T>
  188. vnoremap <S-Tab> <C-D>
  189.  
  190. noremap Y y$
  191. nnoremap \tp :set invpaste paste?<CR>
  192. nmap <F4> \tp
  193. imap <F4> <C-O>\tp
  194. set pastetoggle=<F4>
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. nnoremap <F6> :call Vsplittoggle()<CR>
  202. inoremap <F6> <C-O>:call Vsplittoggle()<CR>
  203.  
  204. function! Vsplittoggle()
  205. let win_num = winnr('$')
  206. if win_num == 1
  207. vnew
  208. set nonumber
  209. wincmd h
  210. else
  211. only
  212. endif
  213. endfunction
  214.  
  215. set lbr
  216. set wrap
  217. set wrap linebreak textwidth=0
  218.  
  219. inoremap <Up> <C-o>gk
  220. inoremap <Down> <C-o>gj
  221. nnoremap <Up> gk
  222. nnoremap <Down> gj
  223.  
  224.  
  225. noremap <S-Down> gj
  226. noremap <S-Up> gk
  227. inoremap <S-Down> <C-O>gh<C-O>gj
  228. inoremap <S-Up> <C-O>gh<C-O>gk
  229. nnoremap <S-Down> gh<C-O>gj
  230. nnoremap <S-Up> gh<C-O>gk
  231.  
  232. inoremap <expr> <Down> pumvisible()?"\<C-N>":"\<Down>"
  233. inoremap <expr> <Up> pumvisible()?"\<C-P>":"\<Up>"
  234. inoremap <expr> <PageDown> pumvisible()?"\<PageDown>\<C-P>\<C-N>":"\<PageDown>"
  235. inoremap <expr> <PageUp> pumvisible()?"\<PageUp>\<C-P>\<C-N>":"\<PageUp>"
  236.  
  237.  
  238. noremap <Space> /
  239. nmap <Space> /
  240. omap <Space> /
  241. nnoremap <CR> i<CR>
  242. nnoremap <Del> i<Del>
  243. nnoremap <BS> i<BS>
  244. nnoremap <Enter> i<Enter>
  245.  
  246. nnoremap <C-z> zz
  247. nnoremap Z zz
  248. nnoremap Za za
  249. nnoremap Zb zb
  250. nnoremap Zc zc
  251. nnoremap Zd zd
  252. nnoremap Ze ze
  253. nnoremap Zf zf
  254. nnoremap Zg zg
  255. nnoremap Zh zh
  256. nnoremap Zi zi
  257. nnoremap Zj zj
  258. nnoremap Zk zk
  259. nnoremap Zl zl
  260. nnoremap Zm zm
  261. nnoremap Zn zn
  262. nnoremap Zo zo
  263. nnoremap Zp zp
  264. nnoremap Zq zq
  265. nnoremap Zr zr
  266. nnoremap Zs zs
  267. nnoremap Zt zt
  268. nnoremap Zu zu
  269. nnoremap Zv zv
  270. nnoremap Zw zw
  271. nnoremap Zx zx
  272. nnoremap Zy zy
  273. nnoremap Zz zz
  274. nnoremap Z. z.
  275. nnoremap Z- z-
  276. nnoremap Z<CR> z<CR>
  277.  
  278. nnoremap za <Nop>
  279. nnoremap zb <Nop>
  280. nnoremap zc <Nop>
  281. nnoremap zd <Nop>
  282. nnoremap ze <Nop>
  283. nnoremap zf <Nop>
  284. nnoremap zg <Nop>
  285. nnoremap zh <Nop>
  286. nnoremap zi <Nop>
  287. nnoremap zj <Nop>
  288. nnoremap zk <Nop>
  289. nnoremap zl <Nop>
  290. nnoremap zm <Nop>
  291. nnoremap zn <Nop>
  292. nnoremap zo <Nop>
  293. nnoremap zp <Nop>
  294. nnoremap zq <Nop>
  295. nnoremap zr <Nop>
  296. nnoremap zs <Nop>
  297. nnoremap zt <Nop>
  298. nnoremap zu <Nop>
  299. nnoremap zv <Nop>
  300. nnoremap zw <Nop>
  301. nnoremap zx <Nop>
  302. nnoremap zy <Nop>
  303. nnoremap zz u
  304. nnoremap z- <Nop>
  305. nnoremap z. <Nop>
  306. nnoremap z<CR> <Nop>
  307.  
  308. nnoremap z0 <Nop>
  309. nnoremap z1 <Nop>
  310. nnoremap z2 <Nop>
  311. nnoremap z3 <Nop>
  312. nnoremap z4 <Nop>
  313. nnoremap z5 <Nop>
  314. nnoremap z6 <Nop>
  315. nnoremap z7 <Nop>
  316. nnoremap z8 <Nop>
  317. nnoremap z9 <Nop>
  318.  
  319.  
  320. nnoremap z^ <Nop>
  321. nnoremap z<Up> <Nop>
  322. nnoremap z<Down> <Nop>
  323. nnoremap z<Left> <Nop>
  324. nnoremap z<Right> <Nop>
  325.  
  326. inoremap <S-Esc> <Esc>l
  327. inoremap kj <Esc>
  328.  
  329.  
  330.  
  331.  
  332. nnoremap <C-S-u> maO<esc>`a
  333. nnoremap <C-u> mao<esc>`a
  334.  
  335. nnoremap @ q
  336. nnoremap <Leader>@ q
  337. nnoremap q @
  338. nnoremap qq @@
  339.  
  340. nnoremap :: :<C-f>
  341. nnoremap :? :<C-f>?
  342.  
  343. nnoremap ; :
  344. nnoremap , ;
  345.  
  346. cabbrev vh vertical help
  347.  
  348. let b:surround_105 = "_\r_"
  349. let b:surround_98 = "__\r__"
  350. let b:surround_97 = "\[\r]\(\1url: \1)"
  351.  
  352. autocmd FileType html let g:surround_105 = "<i>\r</i>"
  353. autocmd FileType html let g:surround_98 = "<b>\r</b>"
  354. autocmd FileType html let g:surround_97 = "<a\1url: \r..*\r href=\"&\"\1 target=\"_blank\">\r</a>"
  355.  
  356.  
  357. hi FixHere ctermfg=Red guifg=Red
  358. let w:m2=matchadd('FixHere', '@@', -1)
  359.  
  360.  
  361.  
  362. func! CompileGcc()
  363. exec "w"
  364. exec "!gcc % -o %<"
  365. endfunc
  366.  
  367. func! CompileRunGcc()
  368. exec "w"
  369. exec "!gcc % -o %<"
  370. exec "! ./%<"
  371. endfunc
  372.  
  373.  
  374.  
  375.  
  376.  
  377. set selectmode= " same as mswin
  378. set mousemodel=popup " same as mswin and dos/win default
  379. set keymodel=startsel " halfway compromise
  380. set selection=inclusive " same as xterm and default
  381. set virtualedit=block,onemore
  382.  
  383. if has("win32")
  384. let g:netrw_cygwin=0
  385. let g:netrw_scp_cmd = "C:\\LocalApps\\Putty\\pscp.exe -q "
  386. let g:netrw_cursorline=1
  387. let g:netrw_silent = 1
  388. :au FocusGained * call getchar(0)
  389. endif
  390. let g:netrw_cursorline=0
  391. let g:netrw_list_hide= '^\..*'
  392.  
  393.  
  394.  
  395. set backspace=indent,eol,start whichwrap+=<,>,[,]
  396.  
  397. vnoremap <BS> d
  398.  
  399. xnoremap <C-X> "+x
  400. xnoremap <S-Del> "+x
  401.  
  402. xnoremap <C-C> "+y
  403. vnoremap <C-C> "+y
  404. xnoremap <C-Insert> "+y
  405. vnoremap <C-Insert> "+y
  406.  
  407. map <C-V> "+gP
  408. map <S-Insert> "+g<Leader>P
  409.  
  410.  
  411. exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
  412. exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
  413.  
  414. imap <S-Insert> <C-V>
  415. xmap <S-Insert> <C-V>
  416.  
  417. noremap <C-Q> <C-V>
  418. cnoremap <C-Q> <C-V>
  419. cnoremap <C-V> <C-R>+
  420.  
  421.  
  422. noremap <C-S> :update<CR>
  423. vnoremap <C-S> <C-C>:update<CR>
  424. inoremap <C-S> <C-O>:update<CR>
  425.  
  426. if has("gui_running")
  427. :map <silent> <C-S> :if expand("%") == ""<CR>:browse confirm w<CR>:else<CR>:update<CR>:endif<CR>
  428. :inoremap <silent> <C-S> <C-O>:if expand("%") == ""<CR><Esc>:browse confirm w<CR>:else<CR>:update<CR>:endif<CR>
  429. endif
  430.  
  431. noremap <C-O> :browse confirm e<CR>
  432.  
  433. noremap <M-[> <C-O>
  434. noremap <M-]> <C-I>
  435.  
  436. if !has("unix")
  437. set guioptions-=a
  438. endif
  439.  
  440. if has("gui")
  441. noremap <M-Space> :simalt ~<CR>
  442. inoremap <M-Space> <C-O>:simalt ~<CR>
  443. cnoremap <M-Space> <C-C>:simalt ~<CR>
  444. endif
  445.  
  446. nmap <C-Down> <Plug>SpeedDatingDown
  447. nmap <C-Up> <Plug>SpeedDatingUp
  448. nmap d<C-X> <Plug>SpeedDatingNowLocal
  449.  
  450. noremap <C-A> :%y+<CR>
  451. noremap <C-S-A> gggH<C-O>G
  452.  
  453.  
  454. set cpo&
  455.  
  456. nnoremap <silent> <Esc> <Esc>:nohlsearch<bar>pclose<bar>call clever_f#reset()<CR>|
  457. nnoremap <S-Tab> i<Tab><Esc><Right>
  458. vnoremap <S-Tab> >gv|
  459. inoremap <S-Tab> <Tab>|
  460.  
  461.  
  462. nnoremap <silent><C-j> m`:silent +g/\m^\s*$/d<CR>``:noh<CR>
  463. nnoremap <silent><C-k> m`:silent -g/\m^\s*$/d<CR>``:noh<CR>
  464. nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
  465. nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
  466.  
  467. cnoremap <C-A> <Home>
  468.  
  469. nmap - "+
  470. xmap - "+
  471.  
  472. nnoremap <Leader>H H
  473. nnoremap <Leader>L L
  474. nnoremap <Leader>M M
  475.  
  476. nnoremap H ^
  477. nnoremap L g_
  478.  
  479.  
  480.  
  481.  
  482.  
  483. function! LookUpwards()
  484. let column_num = virtcol('.')
  485. let target_pattern = '\%' . column_num . 'v.'
  486. let target_line_num = search(target_pattern . '*\S', 'bnW')
  487.  
  488. if !target_line_num
  489. return ""
  490. else
  491. return matchstr(getline(target_line_num), target_pattern)
  492. endif
  493. endfunction
  494.  
  495. inoremap <silent> <C-Y> <C-R><C-R>=LookUpwards()<CR>
  496.  
  497.  
  498.  
  499. vnoremap <silent> <buffer> J :<C-U>'<+1,'>s;^\s*\%(-\?\*\"\<bar>//\)\s*;<space>;e<bar>nohls<CR>gvJ
  500. nnoremap <silent> <buffer> J :<C-U>call JoinComments(v:count)<CR>
  501.  
  502. function! JoinComments(count)
  503. let l:linecount = a:count
  504. if l:linecount < 2
  505. let l:linecount = 2
  506. endif
  507. echo a:count . " lines joined"
  508. let v:errmsg = ''
  509.  
  510. while l:linecount > 1
  511. normal! J
  512. silent! substitute:\%#\s*\%(-\?\*\|//\)\s*: :
  513. silent! substitute:\%#\s*\%(>\)\s: : " for mail quote character
  514. silent! substitute:\%#\s*\%(\"\)\s: : " for vimrc comments
  515. if v:errmsg!~'Pattern not found:'
  516. normal! ``
  517. endif
  518. let l:linecount = l:linecount - 1
  519. endwhile
  520. nohls
  521. endfunction
  522.  
  523. fu! AAa_to_Aaa()
  524. let c = getline(".")[0:col(".")-2]
  525. if c =~ '\v\C<[[:upper:]]{2}[[:lower:]]$'
  526. let pos = getpos('.')
  527. normal hh~
  528. call setpos('.',pos)
  529. endif
  530. endf
  531. :au CursorMovedI * call AAa_to_Aaa()
  532.  
  533. function! PasteJointCharacterwise(regname, pastecmd)
  534. let reg_type = getregtype(a:regname)
  535. let l:newreg = getreg(a:regname)
  536. let l:newreg = substitute(l:newreg, '\n', ' ', 'g')
  537. let l:newreg = substitute(l:newreg, '\^', '\^ ', '')
  538. let l:newreg = substitute(l:newreg, '\$', ' \$', '')
  539. call setreg(a:regname, l:newreg, "c")
  540. normal! mm
  541. exe 'normal "'.a:regname . a:pastecmd
  542. . s / */ /eg
  543. call setreg(a:regname, '', "a".reg_type)
  544. exe 'normal `[v`]J'
  545. normal! `m
  546. endfunction
  547.  
  548. nmap <leader>p :call PasteJointCharacterwise(v:register, "p")<CR>
  549. nmap <leader>P :call PasteJointCharacterwise(v:register, "P")<CR>
  550. nmap g<leader>P :call PasteJointCharacterwise(v:register, "gP")<CR>
  551. nmap g<leader>p :call PasteJointCharacterwise(v:register, "gp")<CR>
  552.  
  553. let g:sentencelines = 0
  554. function! ToggleSentenceLines()
  555. if g:sentencelines
  556. if getline("$") !~ "^\s*$"
  557. $put = ''
  558. endif
  559. silent g /\w\+/ .,/^$/-1join
  560. let &showbreak=''
  561. normal gg
  562. let g:sentencelines = 0
  563. else
  564. silent % s /\([.!?]\+[])"”']*\)\( \{1,2}\([["“('A-Z]\)\)/\1\r\3/g
  565. let &showbreak=' '
  566. normal gg
  567. let g:sentencelines = 1
  568. endif
  569. endfu
  570.  
  571. nnoremap <Leader>s :silent call ToggleSentenceLines()<CR>
  572.  
  573. let g:prose=0
  574. function! ToggleProse()
  575. if g:prose==1
  576. set tw=0
  577. set formatoptions-=at
  578. if getline("$") !~ "^\s*$"
  579. $put = ''
  580. endif
  581. silent g /\w\+/ .,/^$/-1join
  582. let g:prose=0
  583. else
  584. set tw=80
  585. set formatoptions+=at
  586. let g:prose=1
  587. endif
  588. endfunction
  589.  
  590.  
  591.  
  592.  
  593. nmap <F5> :silent call FixQuotes()<CR>
  594.  
  595. map <silent> <leader>qc <Plug>ReplaceWithCurly
  596. map <silent> <leader>qs <Plug>ReplaceWithStraight
  597.  
  598.  
  599. if !exists(":DiffOrig")
  600. command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
  601. \ | wincmd p | diffthis
  602. endif
  603.  
  604.  
  605.  
  606.  
  607. function! WordCount()
  608. if line('$') == 1 && getline(1) == ''
  609. return
  610. elseif mode() == "i" || mode() == "n"
  611. let s:old_status = v:statusmsg
  612. exe "silent normal g\<c-g>"
  613. let b:word_count = str2nr(split(v:statusmsg)[11])
  614. let v:statusmsg = s:old_status
  615. endif
  616. return b:word_count
  617. endfunction
  618.  
  619.  
  620. function! AutoFormatToggle()
  621. if &fo =~ 'a'
  622. setlocal fo-=a
  623. else
  624. setlocal fo+=a
  625. endif
  626. endfu
  627.  
  628. map <F1> :call AutoFormatToggle()<CR>
  629. imap <F1> <Esc>:call AutoFormatToggle()<CR>a
  630.  
  631.  
  632.  
  633. hi default link User1 Identifier
  634. hi default link User2 Statement
  635. hi default link User3 Error
  636. hi default link User4 Special
  637. autocmd ColorScheme * highlight Redd ctermfg=red guifg=red
  638.  
  639. let mystatusline = ""
  640. let mystatusline .= "\ %n\ %*" | " buffer number
  641. let mystatusline .= "\ %<%F%*" | " full path
  642. let mystatusline .= "\ %y%*" | " file type
  643. let mystatusline .= " \%M" | " modified flag
  644. let mystatusline .= "\ %#vimWarn#\%{(&key==\"\"?\"\":\"ENCR\")}%*" | " encrypted?
  645. let mystatusline .= "\ \[%{v:register}\]" | " current register
  646. let mystatusline .= "\ %{getcwd()} " | " current working dir
  647. let mystatusline .= "%=" " left - right separator
  648. let mystatusline .= "0x%04B\ %*" | " character under cursor
  649. let mystatusline .= "\ \ \c\%v\%*" | " column number
  650. let mystatusline .= "/%{len(iconv(getline('.'), &encoding, 'char'))}" | " total columns
  651. let mystatusline .= "%7l%*" | " current line
  652. let mystatusline .= "/%L%*" | " total lines
  653.  
  654.  
  655. let &statusline = mystatusline
  656.  
  657.  
  658. function! WCtoggle()
  659. if &statusline =~ "WC: "
  660. setlocal statusline-=\ \ WC:\ %{WordCount()}\
  661. else
  662. setlocal statusline+=\ \ WC:\ %{WordCount()}\
  663. endif
  664. endfunction
  665.  
  666. nnoremap <Leader>w :silent call WCtoggle()<CR>
  667.  
  668.  
  669.  
  670. function! InsertStatuslineColor(mode)
  671. if a:mode == 'i'
  672. hi statusline guibg=black
  673. hi statusline guifg=gray
  674. hi statusline ctermbg=black
  675. hi statusline ctermfg=gray
  676. elseif a:mode == 'r'
  677. hi statusline guibg=black
  678. hi statusline guifg=gray
  679. hi statusline ctermbg=black
  680. hi statusline ctermfg=white
  681. else
  682. hi statusline guibg=blue
  683. hi statusline guifg=gray
  684. hi statusline ctermbg=blue
  685. hi statusline ctermfg=white
  686. endif
  687. endfunction
  688.  
  689. function! InsertLeaveActions()
  690. hi statusline guibg=blue
  691. hi statusline guifg=gray
  692. hi statusline ctermbg=blue
  693. hi statusline ctermfg=white
  694. endfunction
  695.  
  696. au InsertEnter * call InsertStatuslineColor(v:insertmode)
  697. au InsertLeave * call InsertLeaveActions()
  698.  
  699.  
  700. inoremap <c-c> <c-o>:call InsertLeaveActions()<cr><c-c>
  701.  
  702. set laststatus=2
  703. hi statusline guibg=blue
  704. hi statusline guifg=gray
  705.  
  706.  
  707. function! FixQuotes()
  708. % s /--/ -- /eg
  709. % s /\s*--\s*/ -- /eg
  710. % s / - / -- /eg
  711.  
  712. % s /`/'/eg
  713. % s /\%u2018/'/eg
  714. % s /\%u2019/'/eg
  715. % s /\%u0091/'/eg
  716. % s /\%u0092/'/eg
  717. % s /\%u2030/"/eg
  718. % s /\%u0093/"/eg
  719. % s /\%u0094/"/eg
  720. % s /\%u201c/"/eg
  721. % s /\%u201d/"/eg
  722. % s /\%u201e/"/eg
  723. % s /\%u201a/'/eg
  724. %
  725. % s /\s*\%u97\s*/ -- /eg
  726. % s /\s*—\s*/ -- /eg
  727. % s /\s*\%u2013\s*/ -- /eg
  728. % s /…/.../eg
  729.  
  730. % s /<! -- break -- >/<!--break-->/eg
  731. endfunction
  732.  
  733.  
  734. cabbrev <expr>W ((getcmdtype()==':' && getcmdpos() == 1) ? 'W' : 'w')
  735. cabbrev <expr>Q ((getcmdtype()==':' && getcmdpos() == 1) ? 'Q' : 'q')
  736. cabbrev <expr>Wq ((getcmdtype()==':' && getcmdpos() == 1) ? 'Wq' : 'wq')
  737.  
  738.  
  739. au! FileType mail :nnoremap <buffer> o o<Enter><Enter><Enter><Up><Up>
  740. au! FileType mail :setlocal formatoptions+=a
  741. au! FileType help :setlocal statusline-=\ \ WC:\ %{WordCount()}\
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751. nnoremap <C-S-Tab> :tabprevious<CR>
  752. nnoremap <C-Tab> :tabnext<CR>
  753. noremap <C-S-Tab> :tabprevious<CR>
  754. noremap <C-Tab> :tabnext<CR>
  755. inoremap <C-S-Tab> <Esc>:tabprevious<CR>i
  756. inoremap <C-Tab> <Esc>:tabnext<CR>i
  757. nnoremap <C-t> :tabnew<CR>
  758. inoremap <C-t> <Esc>:tabnew<CR>
  759. noremap <C-F4> :tabclose<CR>
  760.  
  761. :nmap <C-LeftMouse> :Utl ol<cr>
  762.  
  763. :nmap H 0
  764. :nmap L $
  765. :omap H 0
  766. :omap L $
  767.  
  768. func! Eatchar(pat)
  769. let c = nr2char(getchar())
  770. return (c =~ a:pat) ? '' : c
  771. endfunc
  772.  
  773. :map ,c <Plug>NERDCommenterToggle
  774.  
  775. nmap w <Plug>(smartword-w)
  776. nmap b <Plug>(smartword-b)
  777. nmap e <Plug>(smartword-e)
  778. nmap ge <Plug>(smartword-ge)
  779.  
  780.  
  781. :inoreab ddate <C-R>=strftime("%F")<CR>
  782. :cab ddate <C-R>=strftime("%F")<CR>
  783. noreabbrev <silent> ,p <Enter><S-Tab>Paul <Left><C-R>=Eatchar('\s')<CR>
  784. noreabbrev <silent> trb target="_blank" <Left><C-R>=Eatchar('\s')<CR>
  785. iabbrev brk <!--break-->
  786. inoreabbrev <silent> dmer <dme:relatedinfo side="right" /> <Left><C-R>=Eatchar('\s')<CR>
  787. inoreabbrev dts <C-R>=strftime("%Y-%m-%d")<CR>
  788.  
  789.  
  790. inoremap <expr> F ((col('.')>1 && getline('.')[col('.')-2]=~#'^\d$')?((getline('.')[col('.')-4]!~'\.' && getline('.')[col('.')-3]!~'\.')?(printf('°F (%d°C)', float2nr((matchstr(getline('.')[:(col('.')-2)], '\d\+$')-32)/1.8))):(printf('°F (%.1g°C)', (str2float(matchstr(getline('.')[:(col('.')-2)], '\v\-?\d+(\.\d+)?$'))-32)/1.8))):('F'))
  791. inoremap <expr> C ((col('.')>1 && getline('.')[col('.')-2]=~#'^\d$')?((getline('.')[col('.')-4]!~'\.' && getline('.')[col('.')-3]!~'\.')?(printf('°C (%d°F)', float2nr((matchstr(getline('.')[:(col('.')-2)], '\d\+$')*1.8)+32))):(printf('°C (%.1g°F)', (str2float(matchstr(getline('.')[:(col('.')-2)], '\v\-?\d+(\.\d+)?$'))*1.8)+32))):('C'))
  792.  
  793. for buffer_no in range(1, 9)
  794. execute "nmap <A-" . buffer_no . "> :b" . buffer_no . "\<CR>"
  795. endfor
  796.  
  797.  
  798. if &l:filetype ==''
  799. set ft="html"
  800. endif
  801.  
  802. set encoding =utf-8
  803. set formatoptions+=q
  804. set display=lastline
  805.  
  806. runtime plugin/netrwPlugin.vim
  807.  
  808. let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*'
  809.  
  810.  
  811. imap <Space> <Space><c-g>u
  812.  
  813. onoremap <Leader>e //e<CR>
  814. nnoremap <Leader>e //e<CR>
  815.  
  816. function! Smartpaste()
  817. let l:newreg = " "
  818. let l:newreg .= @@
  819. let l:newreg .= " "
  820. call setreg('@', l:newreg, "v")
  821. normal! mmF p
  822. . s / */ /eg
  823. normal! `m
  824. endfu
  825. nmap <C-p> :call Smartpaste()<CR>
  826.  
  827. function! Diary()
  828. if has("unix")
  829. let l:diarydir = "~/Dropbox/notes/diary/"
  830. endif
  831. let l:diaryfilename = l:diarydir . strftime('%Y-%m-%d') . ".txt"
  832. silent execute 'edit' l:diaryfilename
  833. execute ':X'
  834. endfunc
  835.  
  836.  
  837. nnoremap <Leader>3 :call RomanNums()<CR>
  838.  
  839. fun! RomanNums(...)
  840. let numm = (a:0 >= 1) ? a:1 : getline('.')
  841. if numm =~ '^\d*$'
  842. let numm = Arabic2roman(numm)
  843. elseif numm =~ '^\a*$'
  844. let numm = Roman2arabic(numm)
  845. else
  846. echo "Not a number."
  847. endif
  848. silent call setline('.',numm)
  849. endfunction
  850.  
  851. let s:a2r = [[1000, 'm'], [900, 'cm'], [500, 'd'], [400, 'cd'], [100, 'c'],
  852. \ [90 , 'xc'], [50 , 'l'], [40 , 'xl'], [10 , 'x'],
  853. \ [9 , 'ix'], [5 , 'v'], [4 , 'iv'], [1 , 'i']]
  854.  
  855. function! Roman2arabic(roman)
  856. let roman = tolower(a:roman)
  857. let sign = 1
  858. let arabic = 0
  859. while roman != ''
  860. if roman =~ '^[-n]'
  861. let sign = -sign
  862. endif
  863. for [numbers,letters] in s:a2r
  864. if roman =~ '^'.letters
  865. let arabic += sign * numbers
  866. let roman = strpart(roman,strlen(letters)-1)
  867. break
  868. endif
  869. endfor
  870. let roman = strpart(roman,1)
  871. endwhile
  872.  
  873. return arabic
  874. endfunction
  875.  
  876. function! Arabic2roman(arabic)
  877. if a:arabic <= 0
  878. let arabic = -a:arabic
  879. let roman = "n"
  880. else
  881. let arabic = a:arabic
  882. let roman = ""
  883. endif
  884. for [numbers, letters] in s:a2r
  885. let roman .= repeat(letters,arabic/numbers)
  886. let arabic = arabic % numbers
  887. endfor
  888. return toupper(roman)
  889. endfunction
  890.  
  891.  
  892.  
  893. set guioptions-=T
  894. set guicursor+=v:hor10-Cursor
  895.  
  896. let g:speeddating_no_mappings = 1
  897.  
  898.  
  899. xmap \\ <Plug>Commentary
  900. nmap \\ <Plug>Commentary
  901. nmap \\\ <Plug>CommentaryLine
  902. nmap \\u <Plug>CommentaryUndo
  903.  
  904.  
  905.  
  906. let g:force_reload_textobj_sentence = 0
  907.  
  908.  
  909. let g:bullets_enabled_file_types = ['markdown', 'text', 'txt', 'gitcommit']
  910.  
  911.  
  912.  
  913. let g:syntastic_mode_map = { 'mode': 'passive',
  914. \ 'active_filetypes': ['', ''],
  915. \ 'passive_filetypes': ['puppet'] }
  916.  
  917.  
  918. let g:pad_use_default_mappings = 0
  919. let g:pad_format = "txt"
  920. let g:pad_dir = "~/.vim/vimpad"
  921.  
  922. let g:vimroom_clear_line_numbers = 0
  923. let g:vimroom_sidebar_height = 0
  924. nmap <silent> <Leader>v <Plug>VimroomToggle
  925.  
  926. let g:goyo_linenr = 1
  927. let g:goyo_width = 115
  928. let g:goyo_margin_bottom = 0
  929.  
  930. nnoremap <Leader>g :Goyo<CR>
  931.  
  932. let g:peekaboo_prefix = '<leader>'
  933. let g:peekaboo_ins_prefix = '<c-x>'
  934.  
  935. let g:peekaboo_window = 'vertical botright 70new'
  936.  
  937.  
  938. let g:limelight_paragraph_span = 1
  939.  
  940. let g:clever_f_smart_case=1
  941. let g:clever_f_fix_key_direction=1
  942. let g:clever_f_chars_match_any_signs=";"
  943.  
  944. let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
  945. let g:ctrlp_clear_cache_on_exit = 0
  946. let g:ctrlp_custom_ignore = 'itsalltext'
  947. let g:ctrlp_map = '<Leader>t'
  948. nnoremap <Leader>r :CtrlPMRU<CR>
  949. let g:ctrlp_working_path_mode = 0
  950. let g:ctrlp_match_window_reversed = 0
  951. let g:ctrlp_match_window = "bottom,order:btt.min:8,max:15"
  952. let g:ctrlp_max_files = 20000
  953. let g:ctrlp_default_input = 1
  954. let g:ctrlp_dotfiles = 0
  955. let g:ctrlp_prompt_mappings = {
  956. \ 'ToggleType(1)': ['<c-f>', '<c-up>', '<right>' ],
  957. \ 'ToggleType(-1)': ['<c-b>', '<c-down>', '<left>'],
  958. \ 'PrtCurLeft()': ['<c-h>'],
  959. \ 'PrtCurRight()': ['<c-l>'],
  960. \ }
  961. let g:ctrlp_extensions = ['dir']
  962.  
  963.  
  964. let g:snips_trigger_key='<c-\>'
  965.  
  966. let g:ackprg = "ag --vimgrep"
  967. let g:ack_qhandler = "leftabove copen 35"
  968.  
  969.  
  970.  
  971. let g:notes_suffix = '.txt'
  972. let g:notes_smart_quotes = 0
  973.  
  974.  
  975.  
  976.  
  977. if has('gui_running')
  978. autocmd BufEnter * sign define dummy
  979. autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
  980. if has("win32")
  981. set guifont=Fixed:h9:cANSI
  982. set guifontwide=Lucida\ Console:h9
  983. set ambiwidth=double
  984. set lines=70
  985. set columns=212
  986. au GUIEnter * simalt ~x
  987. elseif has("mac")
  988. set columns=200
  989. set lines=65
  990. set noantialias
  991. else
  992. set guifont=Fixed\ 11
  993. set lines=33
  994. set columns=110
  995. endif
  996. else
  997. nmap <Down> <Down>
  998. nmap <Up> <Up>
  999. nmap <Left> <Left>
  1000. nmap <Right> <Right>
  1001. endif
  1002.  
  1003.  
  1004. cnoremap <Up> <Up>
  1005. cnoremap <Down> <Down>
  1006. cnoremap <Left> <Left>
  1007. cnoremap <Right> <Right>
  1008.  
  1009. let g:nv_directories = ['/home/eater/Dropbox/notes/', '/home/eater/Dropbox/Work/cooksscience/notes/']
  1010. let g:nv_default_extension = '.txt'
  1011. let g:nv_main_directory = g:nv_directories[0] " default is first in directory list
  1012. nnoremap <Leader>n :NV<CR>
  1013.  
  1014. if has("mac")
  1015. set rtp+=/Users/padams/homebrew/opt/fzf
  1016. endif
  1017.  
  1018. call plug#begin('~/.vim/plugged')
  1019. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  1020. Plug 'junegunn/fzf.vim'
  1021. Plug 'vim-scripts/MPage'
  1022. Plug 'Alok/notational-fzf-vim'
  1023. Plug 'pbogut/fzf-mru.vim'
  1024. Plug 'justinmk/vim-dirvish'
  1025. Plug 'kshenoy/vim-signature'
  1026. Plug 'tpope/vim-speeddating'
  1027.  
  1028. Plug 'tpope/vim-surround'
  1029. Plug 'tpope/vim-repeat'
  1030. Plug 'tpope/vim-unimpaired'
  1031. Plug 'tpope/vim-commentary'
  1032. Plug 'tpope/vim-fugitive'
  1033. Plug 'tpope/vim-markdown'
  1034. Plug 'mbbill/undotree'
  1035. Plug 'tmhedberg/matchit'
  1036. Plug 'godlygeek/CSApprox'
  1037. Plug 'junegunn/goyo.vim'
  1038. Plug 'junegunn/vim-peekaboo'
  1039. Plug 'junegunn/vim-plug'
  1040. Plug 'inkarkat/Smartput'
  1041. Plug 'skammer/vim-css-color'
  1042. Plug 'gregsexton/MatchTag'
  1043. Plug 'kana/vim-textobj-user'
  1044. Plug 'kana/vim-smartword'
  1045. Plug 'kana/vim-textobj-lastpat'
  1046. Plug 'reedes/vim-textobj-quote'
  1047. Plug 'reedes/vim-textobj-sentence'
  1048. Plug 'beloglazov/vim-textobj-punctuation'
  1049. Plug 'jamessan/vim-gnupg'
  1050. Plug 'arecarn/crunch'
  1051. Plug 'bling/vim-bufferline'
  1052. Plug 'rhysd/clever-f.vim'
  1053. Plug 'mileszs/ack.vim'
  1054. Plug 'clarke/vim-renumber'
  1055. Plug 'MarcWeber/vim-addon-mw-utils'
  1056. Plug 'tomtom/tlib_vim'
  1057. Plug 'vim-scripts/closetag.vim'
  1058. Plug 'vim-scripts/utl.vim'
  1059. Plug 'vim-scripts/RelOps'
  1060. Plug 'vim-scripts/allfold'
  1061.  
  1062. Plug 'dkarter/bullets.vim', { 'frozen' : 1 }
  1063.  
  1064.  
  1065. call plug#end()
  1066.  
  1067.  
  1068. nnoremap <silent> <Leader>f :Files<cr>
  1069. nnoremap <silent> <Leader>d :FZFMru<cr>
  1070. nnoremap <silent> <Leader>b :Lines<cr>
  1071. nnoremap <silent> <Leader>c :FCD<cr>
  1072.  
  1073. function! s:escape(path)
  1074. return substitute(a:path, ' ', '\\ ', 'g')
  1075. endfunction
  1076.  
  1077. function! AgHandler(line)
  1078. let parts = split(a:line, ':')
  1079. let [fn, lno] = parts[0 : 1]
  1080. execute 'e '. s:escape(fn)
  1081. execute lno
  1082. normal! zz
  1083. endfunction
  1084.  
  1085. command! -nargs=+ Fag call fzf#run({
  1086. \ 'source': 'ag --depth=2 -l -t "<args>"',
  1087. \ 'sink': function('AgHandler'),
  1088. \ 'options': '+m',
  1089. \ 'tmux_height': '60%'
  1090. \ })
  1091.  
  1092.  
  1093. command! -nargs=? FCD call fzf#run({
  1094. \ 'source': 'find ~/** -type d -print 2>/dev/null',
  1095. \ 'sink': 'cd' ,
  1096. \ 'tmux_height': '60%' ,
  1097. \ 'options': '-q "<args>" -m --prompt "Directory> "',
  1098. \ })
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104. let g:WriteBackup_BackupDir = '~/.vim/backups'
  1105. let $SWAPDIR = '~/.vim/backups/swap//'
  1106. set directory^=~/.vim/backups/swap//
  1107.  
  1108. syntax on "seems to work best at the end here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement