Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.87 KB | None | 0 0
  1. let g:livepreview_previewer = 'evince'
  2. " ycm {
  3. " set nocompatible
  4. " filetype off
  5. " set rtp+=~/.vim/bundle/vundle.vim
  6. " call vundle#begin()
  7. " plugin 'vundlevim/vundle.vim'
  8. " plugin 'valloric/youcompleteme'
  9. " call vundle#end()
  10. " set omnifunc=syntaxcomplete#complete
  11. " autocmd bufenter * sign define dummy
  12. " autocmd bufenter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
  13. " set splitbelow
  14. " let g:ycm_global_ycm_extra_conf = '~/.vim/ycm_extra_conf.py'
  15. " let g:ycm_autoclose_preview_window_after_completion = 1
  16. " let g:jedi#popup_on_dot = 1
  17. " let g:eclimcompletionmethod = 'omnifunc'
  18. " filetype plugin indent on
  19. " }
  20.  
  21. " main configuration {
  22. syntax on
  23. set ai "autoindent
  24. set si "smartindent
  25. set nu "number
  26. set et "expandtab
  27. set ts=2 "tabstop
  28. set sts=2 "softtabstop
  29. set sw=2 "shiftwidth
  30. set cinw+=forn,forab,ford "cinwords
  31. au filetype c,cpp,h,hpp set cin
  32. set tm=300 "timeoutlen
  33. set spr "splitright
  34. " }
  35.  
  36. autocmd bufread,bufnewfile *.in setfiletype text
  37.  
  38. " mappings {
  39. " map <f4> :!geany %<cr>
  40. map <f4> :w<enter>:!xclip -i -sel clip < %<enter><enter>
  41. map <c-j> 5j
  42. map <c-k> 5k
  43. " imap tt
  44. " imap jj <esc>
  45. " imap jk <esc>:w<cr>
  46. " imap kj <esc>:w<cr>
  47. map H ^
  48. map L $
  49. imap {<cr> {<cr>}<esc>o
  50. " map gc i//<esc>
  51. " map gu ^xx
  52. " }
  53.  
  54. " compile & run {
  55. let $cxxflags = "-o2 -std=c++14 -dlocal -wall -wextra -wno-char-subscripts -wno-unused-result"
  56. " map <f9> :w<enter>:make! %:r<enter>
  57. " imap <f9> <esc>:w<enter>:make! %:r<enter>
  58. " au bufenter *.c,*.cpp,*.h,*.hpp map <f5> :!./%<<cr>
  59. " au bufenter *.py map <f5> :w<enter>:!python3 %<enter>
  60. " au bufenter *.java map <f5> :java %<cr>
  61. " au bufenter *.lua map <f5> :!lua %<cr>
  62. "
  63.  
  64. func! Compile()
  65.     if &filetype == "java"
  66.         :!javac %
  67.     else
  68.         :make! %:r
  69.     endif
  70. endf
  71.  
  72. map <f9> :w<Enter>:call Compile()<Enter>
  73. imap <f9> <Esc>:w<Enter>:call Compile()<Enter>
  74.  
  75.  
  76. func! Run()
  77.     :w
  78.     if &filetype == "python"
  79.         :!python3 %
  80.     elseif &filetype == "text"
  81.         write
  82.         wincmd w
  83.         call Run()
  84.         wincmd w
  85.     elseif &filetype == "java"
  86.         :!java %<
  87.     else
  88.         :!./%<
  89.     endif
  90. endf
  91.  
  92. map <F5> :call Run()<Enter>
  93. imap <F5> <Esc>:call Run()<Enter>
  94. " }
  95.  
  96. " Modern comments {
  97. func! GetCommentString()
  98.     if &filetype == "cpp" || &filetype == "c" || &filetype == "h" || &filetype == "hpp" || &filetype == "java"
  99.         return "//"
  100.     elseif &filetype == "vim"
  101.         return "\" "
  102.     elseif &filetype == "tex"
  103.         return "% "
  104.     elseif &filetype == "lua"
  105.         return "--"
  106.     endif
  107.     return "# "
  108. endf
  109. func! Comment()
  110.     let s = getline(".")
  111.     let pos = 0
  112.     while pos < len(s) && (s[pos] == ' ' || s[pos] == '\t')
  113.         let pos += 1
  114.     endwhile
  115.     if pos < len(s)
  116.         call setline(".", strpart(s, 0, pos) . GetCommentString() . strpart(s, pos))
  117.         let shift = 0
  118.         normal l
  119.         normal l
  120.     endif
  121. endf
  122. func! Uncomment()
  123.     let s = getline(".")
  124.     let comment = GetCommentString()
  125.     let pos = 0
  126.     while pos < len(s) && (s[pos] == ' ' || s[pos] == '\t')
  127.         let pos += 1
  128.     endwhile
  129.     if pos + len(comment) <= len(s)
  130.         if strpart(s, pos, len(comment)) == comment
  131.             call setline(".", strpart(s, 0, pos) . strpart(s, pos + len(comment)))
  132.             normal h
  133.             normal h
  134.         endif
  135.     endif
  136. endf
  137. map gc :call Comment()<cr>
  138. map gu :call Uncomment()<cr>
  139. " }
  140.  
  141. " Abbreviations {
  142. ia templ #include <bits/stdc++.h>
  143. \<cr>using namespace std;
  144. \<cr>#define forn(i,n) for (int i = 0; i < int(n); ++i)
  145. \<cr>#define sz(x) ((int) (x).size())
  146. \<cr>typedef long long ll;
  147. \<cr>typedef long double ld;
  148. \<cr>
  149. " }
  150.  
  151. " Extra menu {
  152. func! Switch()
  153.     echo "h: highlight"
  154.     echo "p: paste"
  155.     echo "c: copy"
  156.     echo ""
  157.     let c = nr2char(getchar())
  158.     if c == 'h'
  159.         set hlsearch!
  160.     elseif c == 'p'
  161.         set paste!
  162.     elseif c == 'c'
  163.         if &nu
  164.             sign unplace 9999
  165.         else
  166.             execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
  167.         endif
  168.         set nu!
  169.     else
  170.         echo "fail"
  171.     endif
  172. endf
  173. map <f8> :call Switch()<cr>
  174. " }
  175.  
  176. " Default template
  177. func! Template()
  178.     " 0r ~/disk/src/templates/jinotega.cpp
  179.     0r ~/disk/src/templates/bufnewfile.cpp
  180.     normal 14j
  181. endf
  182. au BufNewFile *.cpp call Template()
  183.  
  184. " Non-C++ features {
  185. " let g:livepreview_previewer = 'zathura'
  186. au Filetype make setlocal noet
  187. set keymap=russian-jcukenwin
  188. set iminsert=0
  189. set imsearch=0
  190. " map <f4> :!xclip i < %<cr><cr>
  191. " }
  192.  
  193. " let $CPPFLAGS .= " -Wno-misleading-indentation"
  194.  
  195. map <F6> :!xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0<Enter>
  196. map <F7> :!xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1<Enter>
  197.  
  198. set keymap=russian-jcukenwin
  199. set iminsert=0
  200. set imsearch=0
  201. highlight lCursor guifg=NONE guibg=Cyan
  202. imap mm <c-^>
  203. map mm i<c-^><esc>
  204. " map <c-a> ^^
  205. " imap <c-a> ^^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement