Advertisement
Guest User

vim for maksim

a guest
Apr 24th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 11.52 KB | None | 0 0
  1. set nocompatible              " be iMproved, required
  2. filetype off                  " required
  3.  
  4.  
  5.  
  6.  
  7. set backspace=indent,eol,start
  8. " An example for a vimrc file.
  9. "
  10. " Maintainer:   Bram Moolenaar <Bram@vim.org>
  11. " Last change:  2016 Jun 21
  12. "
  13. " To use it, copy it to
  14. "     for Unix and OS/2:  ~/.vimrc
  15. "         for Amiga:  s:.vimrc
  16. "  for MS-DOS and Win32:  $VIM\_vimrc
  17. "       for OpenVMS:  sys$login:.vimrc
  18.  
  19. " When started as "evim", evim.vim will already have done these settings.
  20. if v:progname =~? "evim"
  21.   finish
  22. endif
  23.  
  24. " Use Vim settings, rather than Vi settings (much better!).
  25. " This must be first, because it changes other options as a side effect.
  26. set nocompatible
  27.  
  28. " allow backspacing over everything in insert mode
  29. set backspace=indent,eol,start
  30.  
  31. if has("vms")
  32.   set nobackup      " do not keep a backup file, use versions instead
  33. else
  34.   set backup        " keep a backup file (restore to previous version)
  35.   set undofile      " keep an undo file (undo changes after closing)
  36. endif
  37. set history=50      " keep 50 lines of command line history
  38. set ruler       " show the cursor position all the time
  39. set showcmd     " display incomplete commands
  40. set incsearch       " do incremental searching
  41.  
  42. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  43. " let &guioptions = substitute(&guioptions, "t", "", "g")
  44.  
  45.  
  46. map <C-x> <plug>NERDTreeTabsToggle<CR>
  47.  
  48. if &term =~ "xterm.*"
  49.     let &t_ti = &t_ti . "\e[?2004h"
  50.     let &t_te = "\e[?2004l" . &t_te
  51.     function XTermPasteBegin(ret)
  52.         set pastetoggle=<Esc>[201~
  53.         set paste
  54.         return a:ret
  55.     endfunction
  56.     map <expr> <Esc>[200~ XTermPasteBegin("i")
  57.     imap <expr> <Esc>[200~ XTermPasteBegin("")
  58.     vmap <expr> <Esc>[200~ XTermPasteBegin("c")
  59.     cmap <Esc>[200~ <nop>
  60.     cmap <Esc>[201~ <nop>
  61. endif
  62.  
  63.  
  64. " Don't use Ex mode, use Q for formatting
  65. map Q gq
  66.  
  67. set tabstop=4
  68. set shiftwidth=4
  69. set smarttab
  70. set expandtab
  71. set smartindent
  72. set number
  73.  
  74. " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
  75. " so that you can undo CTRL-U after inserting a line break.
  76. inoremap <C-U> <C-G>u<C-U>
  77.  
  78. " In many terminal emulators the mouse works just fine, thus enable it.
  79. if has('mouse')
  80.   set mouse=a
  81. endif
  82.  
  83. " Switch syntax highlighting on when the terminal has colors or when using the
  84. " GUI (which always has colors).
  85. if &t_Co > 2 || has("gui_running")
  86.   syntax on
  87.  
  88.   " Also switch on highlighting the last used search pattern.
  89.   set hlsearch
  90.  
  91.   " I like highlighting strings inside C comments.
  92.   let c_comment_strings=1
  93. endif
  94.  
  95. " Only do this part when compiled with support for autocommands.
  96. if has("autocmd")
  97.  
  98.   " Enable file type detection.
  99.   " Use the default filetype settings, so that mail gets 'tw' set to 72,
  100.   " 'cindent' is on in C files, etc.
  101.   " Also load indent files, to automatically do language-dependent indenting.
  102.   filetype plugin indent on
  103.  
  104.   " Put these in an autocmd group, so that we can delete them easily.
  105.   augroup vimrcEx
  106.   au!
  107.  
  108.   " For all text files set 'textwidth' to 78 characters.
  109.   autocmd FileType text setlocal textwidth=78
  110.  
  111.   " When editing a file, always jump to the last known cursor position.
  112.   " Don't do it when the position is invalid or when inside an event handler
  113.   " (happens when dropping a file on gvim).
  114.   autocmd BufReadPost *
  115.     \ if line("'\"") >= 1 && line("'\"") <= line("$") |
  116.     \   exe "normal! g`\"" |
  117.     \ endif
  118.  
  119.   augroup END
  120.  
  121. else
  122.  
  123.   set autoindent        " always set autoindenting on
  124.  
  125. endif " has("autocmd")
  126.  
  127. " Convenient command to see the difference between the current buffer and the
  128. " file it was loaded from, thus the changes you made.
  129. " Only define it when not defined already.
  130. if !exists(":DiffOrig")
  131.   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
  132.           \ | wincmd p | diffthis
  133. endif
  134.  
  135. if has('langmap') && exists('+langnoremap')
  136.   " Prevent that the langmap option applies to characters that result from a
  137.   " mapping.  If unset (default), this may break plugins (but it's backward
  138.   " compatible).
  139.   set langnoremap
  140. endif
  141.  
  142.  
  143. " Add optional packages.
  144. "
  145. " The matchit plugin makes the % command work better, but it is not backwards
  146. " compatible.
  147. if has('syntax') && has('eval')
  148.   packadd matchit
  149. endif
  150.  
  151. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  152. " CSCOPE settings for vim          
  153. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  154. "
  155. " This file contains some boilerplate settings for vim's cscope interface,
  156. " plus some keyboard mappings that I've found useful.
  157. "
  158. " USAGE:
  159. " -- vim 6:     Stick this file in your ~/.vim/plugin directory (or in a
  160. "               'plugin' directory in some other directory that is in your
  161. "               'runtimepath'.
  162. "
  163. " -- vim 5:     Stick this file somewhere and 'source cscope.vim' it from
  164. "               your ~/.vimrc file (or cut and paste it into your .vimrc).
  165. "
  166. " NOTE:
  167. " These key maps use multiple keystrokes (2 or 3 keys).  If you find that vim
  168. " keeps timing you out before you can complete them, try changing your timeout
  169. " settings, as explained below.
  170. "
  171. " Happy cscoping,
  172. "
  173. " Jason Duell       jduell@alumni.princeton.edu     2002/3/7
  174. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  175.  
  176.  
  177. " This tests to see if vim was configured with the '--enable-cscope' option
  178. " when it was compiled.  If it wasn't, time to recompile vim...
  179. if has("cscope")
  180.  
  181.     """"""""""""" Standard cscope/vim boilerplate
  182.  
  183.     " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
  184.     set cscopetag
  185.  
  186.     " check cscope for definition of a symbol before checking ctags: set to 1
  187.     " if you want the reverse search order.
  188.     set csto=0
  189.  
  190.     " add any cscope database in current directory
  191.     if filereadable("cscope.out")
  192.         cs add cscope.out  
  193.     " else add the database pointed to by environment variable
  194.     elseif $CSCOPE_DB != ""
  195.         cs add $CSCOPE_DB
  196.     endif
  197.  
  198.     " show msg when any other cscope db added
  199.     set cscopeverbose  
  200.  
  201.  
  202.     """"""""""""" My cscope/vim key mappings
  203.     "
  204.     " The following maps all invoke one of the following cscope search types:
  205.     "
  206.     "   's'   symbol: find all references to the token under cursor
  207.     "   'g'   global: find global definition(s) of the token under cursor
  208.     "   'c'   calls:  find all calls to the function name under cursor
  209.     "   't'   text:   find all instances of the text under cursor
  210.     "   'e'   egrep:  egrep search for the word under cursor
  211.     "   'f'   file:   open the filename under cursor
  212.     "   'i'   includes: find files that include the filename under cursor
  213.     "   'd'   called: find functions that function under cursor calls
  214.     "
  215.     " Below are three sets of the maps: one set that just jumps to your
  216.     " search result, one that splits the existing vim window horizontally and
  217.     " diplays your search result in the new window, and one that does the same
  218.     " thing, but does a vertical split instead (vim 6 only).
  219.     "
  220.     " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
  221.     " unlikely that you need their default mappings (CTRL-\'s default use is
  222.     " as part of CTRL-\ CTRL-N typemap, which basically just does the same
  223.     " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
  224.     " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
  225.     " of these maps to use other keys.  One likely candidate is 'CTRL-_'
  226.     " (which also maps to CTRL-/, which is easier to type).  By default it is
  227.     " used to switch between Hebrew and English keyboard mode.
  228.     "
  229.     " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
  230.     " that searches over '#include <time.h>" return only references to
  231.     " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
  232.     " files that contain 'time.h' as part of their name).
  233.  
  234.  
  235.     " To do the first type of search, hit 'CTRL-\', followed by one of the
  236.     " cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
  237.     " search will be displayed in the current window.  You can use CTRL-T to
  238.     " go back to where you were before the search.  
  239.     "
  240.  
  241.     nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> 
  242.     nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> 
  243.     nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> 
  244.     nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> 
  245.     nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> 
  246.     nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> 
  247.     nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  248.     nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> 
  249.  
  250.  
  251.     " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
  252.     " makes the vim window split horizontally, with search result displayed in
  253.     " the new window.
  254.     "
  255.     " (Note: earlier versions of vim may not have the :scs command, but it
  256.     " can be simulated roughly via:
  257.     "    nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR> 
  258.  
  259.     nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
  260.     nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
  261.     nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
  262.     nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
  263.     nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
  264.     nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
  265.     nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>  
  266.     nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
  267.  
  268.  
  269.     " Hitting CTRL-space *twice* before the search type does a vertical
  270.     " split instead of a horizontal one (vim 6 and up only)
  271.     "
  272.     " (Note: you may wish to put a 'set splitright' in your .vimrc
  273.     " if you prefer the new window on the right instead of the left
  274.  
  275.     nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
  276.     nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
  277.     nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
  278.     nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
  279.     nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
  280.     nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>  
  281.     nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
  282.     nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
  283.  
  284.  
  285.     """"""""""""" key map timeouts
  286.     "
  287.     " By default Vim will only wait 1 second for each keystroke in a mapping.
  288.     " You may find that too short with the above typemaps.  If so, you should
  289.     " either turn off mapping timeouts via 'notimeout'.
  290.     "
  291.     "set notimeout
  292.     "
  293.     " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
  294.     " with your own personal favorite value (in milliseconds):
  295.     "
  296.     "set timeoutlen=4000
  297.     "
  298.     " Either way, since mapping timeout settings by default also set the
  299.     " timeouts for multicharacter 'keys codes' (like <F1>), you should also
  300.     " set ttimeout and ttimeoutlen: otherwise, you will experience strange
  301.     " delays as vim waits for a keystroke after you hit ESC (it will be
  302.     " waiting to see if the ESC is actually part of a key code like <F1>).
  303.     "
  304.     "set ttimeout
  305.     "
  306.     " personally, I find a tenth of a second to work well for key code
  307.     " timeouts. If you experience problems and have a slow terminal or network
  308.     " connection, set it higher.  If you don't set ttimeoutlen, the value for
  309.     " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
  310.     "
  311.     "set ttimeoutlen=100
  312.  
  313. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement