Advertisement
linbojue

Untitled

Dec 7th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 27.64 KB | None | 0 0
  1. " -----------------------------------------------------------------------------
  2. " File          : .vim/贵阳开发票
  3. " Author        : 贵阳开发票▌薇同电▌【159乄1415乄8529】联系:σσ:【5999乄87798】-开各种真发票.哪里有开发票广告、酒店住宿、餐饮、机械设备、服务、建筑、租赁、建材、劳务、办公用品、咨询、材料、工程款、会议.统一国税网查询 , 合作共赢。   Sam Erickson | https://pastebin.com/NN0EQttb
  4. " Last updated  : Oct. 20th, 2018
  5. " -----------------------------------------------------------------------------
  6. "Sets the text width to 80 characters and highlights characters over that limit
  7. set textwidth=80
  8.  
  9. " Add color column to the lines that go over 80 characters
  10. call matchadd('ColorColumn', '\%82v', 100 )
  11.  
  12. " Highlights all characters after the line 80
  13. match ErrorMsg '\%>81v.\+'
  14.  
  15. let mapleader = ","
  16.  
  17. " Set the character for list
  18. set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<,space:·
  19.  
  20. set formatoptions=qcn1jo
  21.  
  22. " Set indenting and tab rules
  23. set autoindent
  24. set smartindent
  25. set wildmenu
  26. set tabstop=2
  27. set nowrap
  28. set shiftwidth=2
  29. set softtabstop=2
  30. set expandtab
  31. set backup
  32. set noswapfile
  33.  
  34. set undodir=~/.vim/tmp/undo//     " undo files
  35. set backupdir=~/.vim/tmp/backup// " backups
  36. set directory=~/.vim/tmp/swap//   " swap files
  37.  
  38. " Make those folders automatically if they don't already exist.
  39. if !isdirectory(expand(&undodir))
  40.     call mkdir(expand(&undodir), "p")
  41. endif
  42. if !isdirectory(expand(&backupdir))
  43.     call mkdir(expand(&backupdir), "p")
  44. endif
  45. if !isdirectory(expand(&directory))
  46.     call mkdir(expand(&directory), "p")
  47. endif
  48.  
  49. " Wild menu settings
  50. set wildmode=list:longest
  51.  
  52. set wildignore+=.hg,.git,.svn                    " Version control
  53. set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
  54. set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
  55. set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
  56. set wildignore+=*.spl                            " compiled spelling word lists
  57. set wildignore+=*.sw?                            " Vim swap files
  58. set wildignore+=*.DS_Store                       " OSX bullshit
  59.  
  60. set wildignore+=*.luac                           " Lua byte code
  61.  
  62. set wildignore+=migrations                       " Django migrations
  63. set wildignore+=*.pyc                            " Python byte code
  64.  
  65. set wildignore+=*.orig                           " Merge resolution files
  66.  
  67. set wildignore+=*.fasl                           " Lisp FASLs
  68. set wildignore+=*.dx64fsl                        " CCL
  69.  
  70. " Allowes language specific vim setting by placing a file in ftplugin/
  71. "   e.g to edit the settings for html files create a file
  72. "   ~/.vim/ftplugin/html.vim and add the rules to that file.
  73. filetype plugin indent on
  74.  
  75. " Make table mode markdown compatible
  76. let g:table_mode_corner='|'
  77. syntax on
  78.  
  79. " LATEX SETTINGS
  80. " Sets the frequency the pdf get updated
  81. au Filetype tex setl updatetime=1
  82.  
  83. " Set the pdf viewing app
  84. let g:livepreview_previewer = 'open -a Preview'
  85.  
  86. " Using grip for github flavoured markdown preview
  87. let vim_markdown_preview_github=1
  88.  
  89. " Runs a script that cleans out tex build files
  90. " whenever I close out of a .tex file.
  91. au VimLeave *.tex !texclear %
  92. " -----------------------------------------------------------------------------
  93. " KEYBINDINGS
  94. " -----------------------------------------------------------------------------
  95.  
  96. " C-T for new tab
  97. nnoremap <C-t> :tabnew<cr>
  98.  
  99. " GRAMMEROUS KEYBINDINGS
  100. nnoremap ;gg :GrammarousCheck<CR>
  101. nnoremap ;gm <Plug>(grammarous-move-to-info-window)
  102.  
  103. " Makes backspace work correctly
  104. set backspace=indent,eol,start
  105.  
  106. map <F4> :setlocal number!<CR>
  107.  
  108.  
  109. "Remove all trailing whitespace by pressing F5
  110. nnoremap ;t :TableModeEnable<CR>
  111.  
  112. " Save using ;s
  113. nnoremap ;s :w<CR>
  114.  
  115. " Environment changing keybindings
  116. nnoremap ;ss :setlocal spell!<CR>
  117. nnoremap ;n :setlocal number! relativenumber!<CR>
  118. nnoremap ;w :set list!<CR>
  119. nnoremap ;p :LLPStartPreview<CR>
  120. nnoremap ;g :Goyo<CR>
  121.  
  122. inoremap ;ss <Esc>:setlocal spell!<CR>i
  123. inoremap ;n <Esc>:setlocal number! relativenumber!<CR>i
  124. inoremap ;w <Esc>:set list!<CR>i
  125. inoremap ;p <Esc>:LLPStartPreview<CR>i
  126. inoremap ;g <esc>:Goyo<CR>i
  127.  
  128. " Yank to end of line
  129. nnoremap Y y$
  130.  
  131. " Change split window keybindings to be faster
  132. map <C-h> <C-w>h
  133. map <C-j> <C-w>j
  134. map <C-k> <C-w>k
  135. map <C-l> <C-w>l
  136.  
  137. " Toggle ruler at line 80
  138. command! ToggleCC :let &cc = &cc == '' ? '81' : ''
  139.  
  140. " Removes all trailing whitespaces
  141. noremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
  142.  
  143. " Show a ruler on line 81
  144. noremap <F9> :let &cc = &cc == '' ? '81' : ''<CR>
  145.  
  146. " Use jk instead of ESC
  147. inoremap jk <ESC>
  148.  
  149. " Make move to the end of the line better
  150. nnoremap 0 $
  151. nnoremap 9 0
  152.  
  153. " Add a banner to a config file
  154. inoremap ;b <Esc>:r ~/.vim/banners/main.txt<CR>
  155.  
  156. " Navigating with guides
  157. inoremap ;l <Esc>/<++><Enter>"_c4l
  158. vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  159. " map <space><tab> <Esc>/<++><Enter>"_c4l
  160.  
  161. " Use // and __ to turn on and off table mode while in insert mode
  162. function! s:isAtStartOfLine(mapping)
  163. let text_before_cursor = getline('.')[0 : col('.')-1]
  164. let mapping_pattern = '\V' . escape(a:mapping, '\')
  165. let comment_pattern = '\V'
  166.       \. escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
  167. return (text_before_cursor =~? '^'
  168.       \. ('\v(' . comment_pattern . '\v)?')
  169.       \. '\s*\v' . mapping_pattern . '\v$')
  170. endfunction
  171.  
  172. inoreabbrev <expr> <bar><bar>
  173. \ <SID>isAtStartOfLine('\|\|') ?
  174. \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
  175. inoreabbrev <expr> __
  176. \ <SID>isAtStartOfLine('__') ?
  177. \ '<c-o>:silent! TableModeDisable<cr>' : '__'
  178. " -----------------------------------------------------------------------------
  179. " QUICK EDITING
  180. " -----------------------------------------------------------------------------
  181. nnoremap <leader>ve :tabnew ~/.vim/vimrc<CR>
  182. nnoremap <leader>ae :tabnew ~/.config/zsh/user_aliases<CR>
  183. nnoremap <leader>ch :tabnew ~/.chunkwmrc<CR>
  184. nnoremap <leader>sk :tabnew ~/.skhdrc<CR>
  185. nnoremap <leader>zs :tabnew ~/.zshrc<CR>
  186.  
  187. " -----------------------------------------------------------------------------
  188. "  PLUGINS
  189. " -----------------------------------------------------------------------------
  190.  
  191. set nocompatible              " be iMproved, required
  192. filetype off                  " required
  193.  
  194. " set the runtime path to include Vundle and initialize
  195. set rtp+=~/.vim/bundle/Vundle.vim
  196. call vundle#begin()
  197.  
  198. " let Vundle manage Vundle, required
  199. Plugin 'VundleVim/Vundle.vim'
  200.  
  201. " A Plugin for distraction free writting in vim
  202. Plugin 'junegunn/goyo.vim'
  203.  
  204. " A Vim Plugin for Lively Previewing LaTeX PDF Output
  205. Plugin 'xuhdev/vim-latex-live-preview'
  206.  
  207. Plugin 'itchyny/lightline.vim'
  208. Plugin 'dhruvasagar/vim-table-mode'
  209.  
  210. " Work with pywal
  211. Plugin 'dylanaraps/wal.vim'
  212.  
  213. " Add grammar checking
  214. Plugin 'rhysd/vim-grammarous'
  215.  
  216. call vundle#end()            " required
  217. filetype plugin indent on    " required
  218.  
  219. " -----------------------------------------------------------------------------
  220. " STATUS BAR
  221. " -----------------------------------------------------------------------------
  222.  
  223. " Makes the status bar look nice
  224. set laststatus=2
  225.  
  226. let g:lightline = {
  227. \ 'colorscheme': 'wombat',
  228. \ 'active': {
  229. \ 'left': [ [ 'mode', 'paste' ],
  230. \           [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
  231. \ },
  232. \ 'component_function': {
  233. \ 'gitbranch': 'fugitive#head'
  234. \ },
  235. \ }
  236.  
  237. " -----------------------------------------------------------------------------
  238. " ABBRIVIATIONS
  239. " -----------------------------------------------------------------------------
  240. " Short cuts
  241. abbr memail me@samerickson.xyz<Esc>A
  242. abbr sweb https://samerickson.xyz<Esc>A
  243. abbr gls https://gitlab.com/samericksn<Esc>A
  244. abbr se Sam Erickson<Esc>A
  245.  
  246. " Common spelling mistakes
  247. abbr ehco echo<Esc>A
  248.  
  249. " -----------------------------------------------------------------------------
  250. " Additional settings that need to be at the end of the file
  251. " -----------------------------------------------------------------------------
  252. colorscheme wal
  253.  
  254. " -----------------------------------------------------------------------------
  255. " HEADERS
  256. " -----------------------------------------------------------------------------
  257. au Filetype html nnoremap ;h :0r ~/.vim/headers/html.txt<CR>
  258. au Filetype sh nnoremap ;h :0r ~/.vim/headers/script.txt<CR>
  259. au Filetype vim nnoremap ;h :0r ~/.vim/headers/vim.txt<CR>
  260. au Filetype cpp nnoremap ;h :0r ~/.vim/headers/cpp.txt<CR>
  261. au Filetype javascript nnoremap ;h :0r ~/.vim/headers/js.txt<CR>
  262. au Filetype css nnoremap ;h :0r ~/.vim/headers/css.txt<CR>
  263. au Filetype tex nnoremap ;h :0r ~/.vim/headers/latex.txt<CR>
  264. au Filetype markdown nnoremap ;h :0r ~/.vim/headers/markdown.txt<CR>
  265.  
  266. " -----------------------------------------------------------------------------
  267. " VIMFILE SNIPPETS
  268. " -----------------------------------------------------------------------------
  269. " Commenting current line
  270. au Filetype vim nnoremap ;c :s!^!" !<CR>
  271. au Filetype vim nnoremap ;u :s!^" !!<CR>
  272. au Filetype vim inoremap ;c <Esc>:s!^!" !<CR>A
  273. au Filetype vim inoremap ;u <Esc>:s!^" !!<CR>A
  274.  
  275. " ----------------------------------------------------------------------------
  276. " MARKDOWN SNIPPETS
  277. " -----------------------------------------------------------------------------
  278. au Filetype markdown inoremap ,n ---<Enter><Enter>
  279. au Filetype markdown inoremap ,b ****<++><Esc>F*hi
  280. au Filetype markdown inoremap ,s ~~~~<++><Esc>F~hi
  281. au Filetype markdown inoremap ,e **<++><Esc>F*i
  282. au Filetype markdown inoremap ,h ====<Space><++><Esc>F=hi
  283. au Filetype markdown inoremap ,i ![](<++>)<++><Esc>F[a
  284. au Filetype markdown inoremap ,a [](<++>)<++><Esc>F[a
  285. au Filetype markdown inoremap ,1 #<Space><Enter><++><Esc>kA
  286. au Filetype markdown inoremap ,2 ##<Space><Enter><++><Esc>kA
  287. au Filetype markdown inoremap ,3 ###<Space><Enter><++><Esc>kA
  288. au Filetype markdown inoremap ,l --------<Enter>
  289. au Filetype markdown inoremap ,c ```<CR><CR>```<CR><CR><++><Esc>3ki
  290.  
  291. " For kmarkdown, while writting my blog
  292. au Filetype markdown inoremap
  293. \,h {% highlight  %}<CR><++><CR>{% endhighlight %}<CR><CR><++><Esc>4k10li
  294.  
  295. " -----------------------------------------------------------------------------
  296. " CPP SNIPPETS
  297. " -----------------------------------------------------------------------------
  298.  
  299. " -----------------------------------------------------------------------------
  300. " CSS SNIPPETS
  301. " -----------------------------------------------------------------------------
  302. au Filetype css inoremap ;c /*  */<++><Esc>7h
  303. au Filetype css nnoremap ;c :s/^\(.*\)$//* \1 *//<CR>
  304.  
  305. " -----------------------------------------------------------------------------
  306. " HTML SNIPPETS
  307. " -----------------------------------------------------------------------------
  308. " Comments
  309. au Filetype html nnoremap ;u :s/^\(.*\)$/<!-- \1 -->/<CR>
  310. au Filetype html inoremap ;c <!--   --><CR><++><Esc>k2li
  311.  
  312. " Header
  313.  
  314. " Elements
  315. au Filetype html inoremap ,b <b></b><Space><++><Esc>FbT>i
  316. au Filetype html inoremap ,it <em></em><Space><++><Esc>FeT>i
  317. au Filetype html inoremap ,1 <h1></h1><Enter><Enter><++><Esc>2kf<i
  318. au Filetype html inoremap ,2 <h2></h2><Enter><Enter><++><Esc>2kf<i
  319. au Filetype html inoremap ,3 <h3></h3><Enter><Enter><++><Esc>2kf<i
  320. au Filetype html inoremap ,p <p></p><Enter><Enter><++><Esc>02kf>a
  321. au Filetype html inoremap ,a <a<Space>href=""><++></a><Space><++><Esc>14hi
  322. au Filetype html inoremap ,li <Esc>o<li></li><Esc>F>a
  323. au Filetype html inoremap ,im <img src="" alt="<++>"><++><esc>Fcf"a
  324. au Filetype html inoremap ,td <td></td><++><Esc>Fdcit
  325. au Filetype html inoremap ,tr <tr></tr><Enter><++><Esc>kf<i
  326. au Filetype html inoremap ,th <th></th><++><Esc>Fhcit
  327. au Filetype html inoremap ,tab <table><Enter></table><Esc>O
  328. au Filetype html inoremap ,dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit
  329. au Filetype html inoremap ,dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc
  330. au Filetype html inoremap ,e
  331.       \<a<Space>target="_blank"<Space>href=""><++></a><Space><++><Esc>14hi
  332. au Filetype html inoremap ,ul
  333.       \<ul><Enter><li></li><Enter></ul><Enter><Enter><++><Esc>03kf<i
  334. au Filetype html inoremap ,ol
  335.       \<ol><Enter><li></li><Enter></ol><Enter><Enter><++><Esc>03kf<i
  336. " -----------------------------------------------------------------------------
  337. " LATEX SNIPPETS
  338. " -----------------------------------------------------------------------------
  339. au FileType tex inoremap ,em \emph{}<++><Esc>T{i
  340. au FileType tex inoremap ,bf \textbf{}<++><Esc>T{i
  341. au FileType tex inoremap ,li <Enter>\item<Space>
  342. au FIleType tex inoremap ,n \linebreak<CR><CR>
  343. au FileType tex inoremap ,sec \section{}<Enter><Enter><++><Esc>2kf}i
  344. au FileType tex inoremap ,ssec \subsection{}<Enter><Enter><++><Esc>2kf}i
  345. au FileType tex inoremap ,sssec \subsubsection{}<Enter><Enter><++><Esc>2kf}i
  346. au FileType tex inoremap ,ul \begin{itemize}<Enter><Enter>\end{itemize}<Enter><Enter><++><Esc>3kA\item<Space>
  347.  
  348. " Fix markdown syntax when writting posts for my blog
  349. function! MathAndLiquid()
  350.   "" Define certain regions
  351.   " Block math. Look for "$$[anything]$$"
  352.   syn region math start=/\$\$/ end=/\$\$/
  353.   " inline math. Look for "$[not $][anything]$"
  354.   syn match math_block '\$[^$].\{-}\$'
  355.  
  356.   " Liquid single line. Look for "{%[anything]%}"
  357.   syn match liquid '{%.*%}'
  358.   " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
  359.   syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
  360.   " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
  361.   syn region highlight_block start='```' end='```'
  362.  
  363.   "" Actually highlight those regions.
  364.   hi link math Statement
  365.   hi link liquid Statement
  366.   hi link highlight_block Function
  367.   hi link math_block Function
  368. endfunction
  369.  
  370. " Call everytime we open a Markdown file
  371. autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()" -----------------------------------------------------------------------------
  372. " File          : .贵阳/贵阳开发票
  373. " Author        : 贵阳开发票▌薇同电▌【159乄1415乄8529】联系:σσ:【5999乄87798】-开各种真发票.哪里有开发票广告、酒店住宿、餐饮、机械设备、服务、建筑、租赁、建材、劳务、办公用品、咨询、材料、工程款、会议.统一国税网查询 , 合作共赢。   Sam Erickson | https://pastebin.com/NN0EQttb
  374. " Last updated  : Oct. 20th, 2018
  375. " -----------------------------------------------------------------------------
  376. "Sets the text width to 80 characters and highlights characters over that limit
  377. set textwidth=80
  378.  
  379. " Add color column to the lines that go over 80 characters
  380. call matchadd('ColorColumn', '\%82v', 100 )
  381.  
  382. " Highlights all characters after the line 80
  383. match ErrorMsg '\%>81v.\+'
  384.  
  385. let mapleader = ","
  386.  
  387. " Set the character for list
  388. set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<,space:·
  389.  
  390. set formatoptions=qcn1jo
  391.  
  392. " Set indenting and tab rules
  393. set autoindent
  394. set smartindent
  395. set wildmenu
  396. set tabstop=2
  397. set nowrap
  398. set shiftwidth=2
  399. set softtabstop=2
  400. set expandtab
  401. set backup
  402. set noswapfile
  403.  
  404. set undodir=~/.vim/tmp/undo//     " undo files
  405. set backupdir=~/.vim/tmp/backup// " backups
  406. set directory=~/.vim/tmp/swap//   " swap files
  407.  
  408. " Make those folders automatically if they don't already exist.
  409. if !isdirectory(expand(&undodir))
  410.     call mkdir(expand(&undodir), "p")
  411. endif
  412. if !isdirectory(expand(&backupdir))
  413.     call mkdir(expand(&backupdir), "p")
  414. endif
  415. if !isdirectory(expand(&directory))
  416.     call mkdir(expand(&directory), "p")
  417. endif
  418.  
  419. " Wild menu settings
  420. set wildmode=list:longest
  421.  
  422. set wildignore+=.hg,.git,.svn                    " Version control
  423. set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
  424. set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
  425. set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
  426. set wildignore+=*.spl                            " compiled spelling word lists
  427. set wildignore+=*.sw?                            " Vim swap files
  428. set wildignore+=*.DS_Store                       " OSX bullshit
  429.  
  430. set wildignore+=*.luac                           " Lua byte code
  431.  
  432. set wildignore+=migrations                       " Django migrations
  433. set wildignore+=*.pyc                            " Python byte code
  434.  
  435. set wildignore+=*.orig                           " Merge resolution files
  436.  
  437. set wildignore+=*.fasl                           " Lisp FASLs
  438. set wildignore+=*.dx64fsl                        " CCL
  439.  
  440. " Allowes language specific vim setting by placing a file in ftplugin/
  441. "   e.g to edit the settings for html files create a file
  442. "   ~/.vim/ftplugin/html.vim and add the rules to that file.
  443. filetype plugin indent on
  444.  
  445. " Make table mode markdown compatible
  446. let g:table_mode_corner='|'
  447. syntax on
  448.  
  449. " LATEX SETTINGS
  450. " Sets the frequency the pdf get updated
  451. au Filetype tex setl updatetime=1
  452.  
  453. " Set the pdf viewing app
  454. let g:livepreview_previewer = 'open -a Preview'
  455.  
  456. " Using grip for github flavoured markdown preview
  457. let vim_markdown_preview_github=1
  458.  
  459. " Runs a script that cleans out tex build files
  460. " whenever I close out of a .tex file.
  461. au VimLeave *.tex !texclear %
  462. " -----------------------------------------------------------------------------
  463. " KEYBINDINGS
  464. " -----------------------------------------------------------------------------
  465.  
  466. " C-T for new tab
  467. nnoremap <C-t> :tabnew<cr>
  468.  
  469. " GRAMMEROUS KEYBINDINGS
  470. nnoremap ;gg :GrammarousCheck<CR>
  471. nnoremap ;gm <Plug>(grammarous-move-to-info-window)
  472.  
  473. " Makes backspace work correctly
  474. set backspace=indent,eol,start
  475.  
  476. map <F4> :setlocal number!<CR>
  477.  
  478.  
  479. "Remove all trailing whitespace by pressing F5
  480. nnoremap ;t :TableModeEnable<CR>
  481.  
  482. " Save using ;s
  483. nnoremap ;s :w<CR>
  484.  
  485. " Environment changing keybindings
  486. nnoremap ;ss :setlocal spell!<CR>
  487. nnoremap ;n :setlocal number! relativenumber!<CR>
  488. nnoremap ;w :set list!<CR>
  489. nnoremap ;p :LLPStartPreview<CR>
  490. nnoremap ;g :Goyo<CR>
  491.  
  492. inoremap ;ss <Esc>:setlocal spell!<CR>i
  493. inoremap ;n <Esc>:setlocal number! relativenumber!<CR>i
  494. inoremap ;w <Esc>:set list!<CR>i
  495. inoremap ;p <Esc>:LLPStartPreview<CR>i
  496. inoremap ;g <esc>:Goyo<CR>i
  497.  
  498. " Yank to end of line
  499. nnoremap Y y$
  500.  
  501. " Change split window keybindings to be faster
  502. map <C-h> <C-w>h
  503. map <C-j> <C-w>j
  504. map <C-k> <C-w>k
  505. map <C-l> <C-w>l
  506.  
  507. " Toggle ruler at line 80
  508. command! ToggleCC :let &cc = &cc == '' ? '81' : ''
  509.  
  510. " Removes all trailing whitespaces
  511. noremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
  512.  
  513. " Show a ruler on line 81
  514. noremap <F9> :let &cc = &cc == '' ? '81' : ''<CR>
  515.  
  516. " Use jk instead of ESC
  517. inoremap jk <ESC>
  518.  
  519. " Make move to the end of the line better
  520. nnoremap 0 $
  521. nnoremap 9 0
  522.  
  523. " Add a banner to a config file
  524. inoremap ;b <Esc>:r ~/.vim/banners/main.txt<CR>
  525.  
  526. " Navigating with guides
  527. inoremap ;l <Esc>/<++><Enter>"_c4l
  528. vnoremap <Space><Tab> <Esc>/<++><Enter>"_c4l
  529. " map <space><tab> <Esc>/<++><Enter>"_c4l
  530.  
  531. " Use // and __ to turn on and off table mode while in insert mode
  532. function! s:isAtStartOfLine(mapping)
  533. let text_before_cursor = getline('.')[0 : col('.')-1]
  534. let mapping_pattern = '\V' . escape(a:mapping, '\')
  535. let comment_pattern = '\V'
  536.       \. escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
  537. return (text_before_cursor =~? '^'
  538.       \. ('\v(' . comment_pattern . '\v)?')
  539.       \. '\s*\v' . mapping_pattern . '\v$')
  540. endfunction
  541.  
  542. inoreabbrev <expr> <bar><bar>
  543. \ <SID>isAtStartOfLine('\|\|') ?
  544. \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
  545. inoreabbrev <expr> __
  546. \ <SID>isAtStartOfLine('__') ?
  547. \ '<c-o>:silent! TableModeDisable<cr>' : '__'
  548. " -----------------------------------------------------------------------------
  549. " QUICK EDITING
  550. " -----------------------------------------------------------------------------
  551. nnoremap <leader>ve :tabnew ~/.vim/vimrc<CR>
  552. nnoremap <leader>ae :tabnew ~/.config/zsh/user_aliases<CR>
  553. nnoremap <leader>ch :tabnew ~/.chunkwmrc<CR>
  554. nnoremap <leader>sk :tabnew ~/.skhdrc<CR>
  555. nnoremap <leader>zs :tabnew ~/.zshrc<CR>
  556.  
  557. " -----------------------------------------------------------------------------
  558. "  PLUGINS
  559. " -----------------------------------------------------------------------------
  560.  
  561. set nocompatible              " be iMproved, required
  562. filetype off                  " required
  563.  
  564. " set the runtime path to include Vundle and initialize
  565. set rtp+=~/.vim/bundle/Vundle.vim
  566. call vundle#begin()
  567.  
  568. " let Vundle manage Vundle, required
  569. Plugin 'VundleVim/Vundle.vim'
  570.  
  571. " A Plugin for distraction free writting in vim
  572. Plugin 'junegunn/goyo.vim'
  573.  
  574. " A Vim Plugin for Lively Previewing LaTeX PDF Output
  575. Plugin 'xuhdev/vim-latex-live-preview'
  576.  
  577. Plugin 'itchyny/lightline.vim'
  578. Plugin 'dhruvasagar/vim-table-mode'
  579.  
  580. " Work with pywal
  581. Plugin 'dylanaraps/wal.vim'
  582.  
  583. " Add grammar checking
  584. Plugin 'rhysd/vim-grammarous'
  585.  
  586. call vundle#end()            " required
  587. filetype plugin indent on    " required
  588.  
  589. " -----------------------------------------------------------------------------
  590. " STATUS BAR
  591. " -----------------------------------------------------------------------------
  592.  
  593. " Makes the status bar look nice
  594. set laststatus=2
  595.  
  596. let g:lightline = {
  597. \ 'colorscheme': 'wombat',
  598. \ 'active': {
  599. \ 'left': [ [ 'mode', 'paste' ],
  600. \           [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
  601. \ },
  602. \ 'component_function': {
  603. \ 'gitbranch': 'fugitive#head'
  604. \ },
  605. \ }
  606.  
  607. " -----------------------------------------------------------------------------
  608. " ABBRIVIATIONS
  609. " -----------------------------------------------------------------------------
  610. " Short cuts
  611. abbr memail me@samerickson.xyz<Esc>A
  612. abbr sweb https://samerickson.xyz<Esc>A
  613. abbr gls https://gitlab.com/samericksn<Esc>A
  614. abbr se Sam Erickson<Esc>A
  615.  
  616. " Common spelling mistakes
  617. abbr ehco echo<Esc>A
  618.  
  619. " -----------------------------------------------------------------------------
  620. " Additional settings that need to be at the end of the file
  621. " -----------------------------------------------------------------------------
  622. colorscheme wal
  623.  
  624. " -----------------------------------------------------------------------------
  625. " HEADERS
  626. " -----------------------------------------------------------------------------
  627. au Filetype html nnoremap ;h :0r ~/.vim/headers/html.txt<CR>
  628. au Filetype sh nnoremap ;h :0r ~/.vim/headers/script.txt<CR>
  629. au Filetype vim nnoremap ;h :0r ~/.vim/headers/vim.txt<CR>
  630. au Filetype cpp nnoremap ;h :0r ~/.vim/headers/cpp.txt<CR>
  631. au Filetype javascript nnoremap ;h :0r ~/.vim/headers/js.txt<CR>
  632. au Filetype css nnoremap ;h :0r ~/.vim/headers/css.txt<CR>
  633. au Filetype tex nnoremap ;h :0r ~/.vim/headers/latex.txt<CR>
  634. au Filetype markdown nnoremap ;h :0r ~/.vim/headers/markdown.txt<CR>
  635.  
  636. " -----------------------------------------------------------------------------
  637. " VIMFILE SNIPPETS
  638. " -----------------------------------------------------------------------------
  639. " Commenting current line
  640. au Filetype vim nnoremap ;c :s!^!" !<CR>
  641. au Filetype vim nnoremap ;u :s!^" !!<CR>
  642. au Filetype vim inoremap ;c <Esc>:s!^!" !<CR>A
  643. au Filetype vim inoremap ;u <Esc>:s!^" !!<CR>A
  644.  
  645. " ----------------------------------------------------------------------------
  646. " MARKDOWN SNIPPETS
  647. " -----------------------------------------------------------------------------
  648. au Filetype markdown inoremap ,n ---<Enter><Enter>
  649. au Filetype markdown inoremap ,b ****<++><Esc>F*hi
  650. au Filetype markdown inoremap ,s ~~~~<++><Esc>F~hi
  651. au Filetype markdown inoremap ,e **<++><Esc>F*i
  652. au Filetype markdown inoremap ,h ====<Space><++><Esc>F=hi
  653. au Filetype markdown inoremap ,i ![](<++>)<++><Esc>F[a
  654. au Filetype markdown inoremap ,a [](<++>)<++><Esc>F[a
  655. au Filetype markdown inoremap ,1 #<Space><Enter><++><Esc>kA
  656. au Filetype markdown inoremap ,2 ##<Space><Enter><++><Esc>kA
  657. au Filetype markdown inoremap ,3 ###<Space><Enter><++><Esc>kA
  658. au Filetype markdown inoremap ,l --------<Enter>
  659. au Filetype markdown inoremap ,c ```<CR><CR>```<CR><CR><++><Esc>3ki
  660.  
  661. " For kmarkdown, while writting my blog
  662. au Filetype markdown inoremap
  663. \,h {% highlight  %}<CR><++><CR>{% endhighlight %}<CR><CR><++><Esc>4k10li
  664.  
  665. " -----------------------------------------------------------------------------
  666. " CPP SNIPPETS
  667. " -----------------------------------------------------------------------------
  668.  
  669. " -----------------------------------------------------------------------------
  670. " CSS SNIPPETS
  671. " -----------------------------------------------------------------------------
  672. au Filetype css inoremap ;c /*  */<++><Esc>7h
  673. au Filetype css nnoremap ;c :s/^\(.*\)$//* \1 *//<CR>
  674.  
  675. " -----------------------------------------------------------------------------
  676. " HTML SNIPPETS
  677. " -----------------------------------------------------------------------------
  678. " Comments
  679. au Filetype html nnoremap ;u :s/^\(.*\)$/<!-- \1 -->/<CR>
  680. au Filetype html inoremap ;c <!--   --><CR><++><Esc>k2li
  681.  
  682. " Header
  683.  
  684. " Elements
  685. au Filetype html inoremap ,b <b></b><Space><++><Esc>FbT>i
  686. au Filetype html inoremap ,it <em></em><Space><++><Esc>FeT>i
  687. au Filetype html inoremap ,1 <h1></h1><Enter><Enter><++><Esc>2kf<i
  688. au Filetype html inoremap ,2 <h2></h2><Enter><Enter><++><Esc>2kf<i
  689. au Filetype html inoremap ,3 <h3></h3><Enter><Enter><++><Esc>2kf<i
  690. au Filetype html inoremap ,p <p></p><Enter><Enter><++><Esc>02kf>a
  691. au Filetype html inoremap ,a <a<Space>href=""><++></a><Space><++><Esc>14hi
  692. au Filetype html inoremap ,li <Esc>o<li></li><Esc>F>a
  693. au Filetype html inoremap ,im <img src="" alt="<++>"><++><esc>Fcf"a
  694. au Filetype html inoremap ,td <td></td><++><Esc>Fdcit
  695. au Filetype html inoremap ,tr <tr></tr><Enter><++><Esc>kf<i
  696. au Filetype html inoremap ,th <th></th><++><Esc>Fhcit
  697. au Filetype html inoremap ,tab <table><Enter></table><Esc>O
  698. au Filetype html inoremap ,dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit
  699. au Filetype html inoremap ,dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc
  700. au Filetype html inoremap ,e
  701.       \<a<Space>target="_blank"<Space>href=""><++></a><Space><++><Esc>14hi
  702. au Filetype html inoremap ,ul
  703.       \<ul><Enter><li></li><Enter></ul><Enter><Enter><++><Esc>03kf<i
  704. au Filetype html inoremap ,ol
  705.       \<ol><Enter><li></li><Enter></ol><Enter><Enter><++><Esc>03kf<i
  706. " -----------------------------------------------------------------------------
  707. " LATEX SNIPPETS
  708. " -----------------------------------------------------------------------------
  709. au FileType tex inoremap ,em \emph{}<++><Esc>T{i
  710. au FileType tex inoremap ,bf \textbf{}<++><Esc>T{i
  711. au FileType tex inoremap ,li <Enter>\item<Space>
  712. au FIleType tex inoremap ,n \linebreak<CR><CR>
  713. au FileType tex inoremap ,sec \section{}<Enter><Enter><++><Esc>2kf}i
  714. au FileType tex inoremap ,ssec \subsection{}<Enter><Enter><++><Esc>2kf}i
  715. au FileType tex inoremap ,sssec \subsubsection{}<Enter><Enter><++><Esc>2kf}i
  716. au FileType tex inoremap ,ul \begin{itemize}<Enter><Enter>\end{itemize}<Enter><Enter><++><Esc>3kA\item<Space>
  717.  
  718. " Fix markdown syntax when writting posts for my blog
  719. function! MathAndLiquid()
  720.   "" Define certain regions
  721.   " Block math. Look for "$$[anything]$$"
  722.   syn region math start=/\$\$/ end=/\$\$/
  723.   " inline math. Look for "$[not $][anything]$"
  724.   syn match math_block '\$[^$].\{-}\$'
  725.  
  726.   " Liquid single line. Look for "{%[anything]%}"
  727.   syn match liquid '{%.*%}'
  728.   " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
  729.   syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
  730.   " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
  731.   syn region highlight_block start='```' end='```'
  732.  
  733.   "" Actually highlight those regions.
  734.   hi link math Statement
  735.   hi link liquid Statement
  736.   hi link highlight_block Function
  737.   hi link math_block Function
  738. endfunction
  739.  
  740. " Call everytime we open a Markdown file
  741. autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement