vim配置

自用的vim配置信息

syntax on  
syntax enable
"" 设置历史记录条数  
set history=2000  

"" create undo file
set undolevels=1000 "" how many undos
set undoreload=10000 "" number of lines to save for undo
if v:version >= 730
    set undofile     "" keep a persistent backup file
    set undodir=/tmp/vimundo/
endif

""set wildignore=*.swp,*.bak,*.pyc,*.class,.svn

"" 显示当前横竖线  
set cursorline  
set cursorcolumn  

"" 设置退出Vim之后内容显示在终端屏幕,可以用于查看和复制
"" 好处:误删什么,如果以前屏幕打开可以用来找回
set t_ti= t_te=

"" 设置在Vim中可以使用鼠标,防止终端无法拷贝  
set mouse=a  

""==========================================
"" Display Settings
""==========================================
""
"" 显示当前行号和列号
set ruler

"" 在状态栏显示正在输入的命令
set showcmd

"" 左下角显示当前Vim模式
set showmode

"" 光标移动至少保留的行数
""set scrolloff=7

"" 总是显示状态栏 Powerline需要2行  
set laststatus=2  

" 高亮显示普通txt文件(需要txt.vim脚本)
au BufRead,BufNewFile *  setfiletype txt

"" 显示行号  
set number  

"" 指定不折行
set nowrap  

"" 设置代码匹配,包括括号匹配情况  
set showmatch  

"" how many tenths of a second to blink when matching brackets
"" setmatchtime=2

"" 开启及时搜索  
set incsearch  

"" 设置搜索高亮  
set hls  

"" 设置搜索时忽略大小写  
set ignorecase  

"" 当搜索的时候尝试smart  
set smartcase  

"" 设置代码折叠
""set foldenable
"" 折叠方法
"" manual 手工折叠
"" indent 缩进折叠
"" expr 表达式折叠
"" syntax 语法折叠
"" diff 对没有更改的文件折叠
"" marker 标记折叠
""set foldmethod=indent
""set foldlevel=99

"" 设置C/C++方式自动对齐  
set autoindent  
set cindent  
set smartindent  

"" 设置tab宽度  
set tabstop=4

"" 设置自动对齐空格数  
set shiftwidth=4  

"" 按退格键时可以一次删除4个空格
""set softtabstop=4

 "" 编辑的时候将所有的tab设置为空格  
""" set et  

set noexpandtab

 "" 使用Backspace直接删除tab  
 set smarttab  

"" 不在单词中间折行  
set lbr  
 ""==========================================
 "" FileEncode Settings
 ""==========================================

 "" 设置编码方式  
 set encoding=utf-8  

 "" 设置打开文件的编码格式  
 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1  

 set helplang=cn 

 "" 只对终端影响
 set termencoding=utf-8

 "" use UNIX as the standard file type
 set ffs=unix,dos,mac

"" 如遇Unicode值大于255的文本,不必等到空格再折行。
set formatoptions+=m

"" 合并两行中文时,不在中间加空格:
set formatoptions+=B

""==========================================
"" Other Settings
""==========================================
 "" 自动补全配置让Vim补全菜单行为跟IDE一致
 set completeopt=longest,menu

 "" 增强模式中的命令行自动完成操作
 set wildmenu

 "" ignore compiled files
 "" set wildignore=*.o,*~,*.pyc,*.class

""离开插入模式后自动关闭预览窗口
"autocmd InsertLeave * if pumvisible == 0|pclose|endif
map / :nohls
map tn :tabnew
map to :tabonly
map tc :tabclose
map tm :tabmove

"" Opens a new tab with the current buffer's path
"" Super useful when editing files in the same directory
map te :tabedit =expand/

"" Quickly edit/reload the vimrc file
nmap  ev :e $MYVIMRC
nmap  sv :so $MYVIMRC

"" 手动刷新tags
nmap tg :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q *:set tags+=./tags:!cscope -Rbq:cs add ./cscope.out .

"" 切换buffer
nnoremap [b :bp
nnoremap ]b :bn

""map :!cscope -Rbq:cs add ./cscope.out . :cs reset
"" 查找符号
nmap css :cs find s =expand :copen
"" 查找定义
nmap csg :cs find g =expand
"" 查找被这个函数调用的函数
nmap csd :cs find d =expand :copen
"" 查找调用这个函数的函数
nmap csc :cs find c =expand:copen
"" 查找这个字符串
nmap cst :cs find t =expand:copen
"" 查找这个egrep匹配模式
nmap cse :cs find e =expand:copen
"" 查找这个文件
nmap csf :cs find f =expand
"" 查找include这个文件的文件
nmap csi :cs find i =expand :copen

"" 设定是否使用QuickFix来显示结果
set cscopequickfix=s-,c-,d-,i-,t-,e-

"" QuickFix open and close
nnoremap  :copen
nnoremap  :cclose

"" QucikFix next and prev
nnoremap  :cn
nnoremap  :cp

""==========================================
"" Theme Settings
""==========================================

"" Set extra options when running in GUI mode
""if has
""    set guifont=Monaco\ 12
""    set guioptions-=T
""    set guioptions+=e
""    set guioptions-=r
""    set guioptions-=L
""    set guitablabel=%M\ %t
""    set showtabline=1 
""    set linespace=2 
""    set noimd   
""    set t_Co=256
""endif

"" 设置主题  
set background=dark

"" 添加水平滚动条  
""set guioptions+=b  

"" 取消菜单栏和导航栏  
set guioptions-=m  
set guioptions-=T  

"" 去除左右两边滚动条
set go-=r
set go-=L

"" 设置水平行数和竖直列数  
"" set lines=35  
"" set columns=99  

"" vim-scripts repos  
"" non-GitHub repos  
"" Git repos on your local machine   

""==========================================
"" ctrlp settings  
""==========================================
""let g:ctrlp_map = 'p'
""let g:ctrlp_cmd = 'CtrlP'
""map f :CtrlPMRU
""set wildignore+=*/tmp/*,*.so,*.swp,*.zip     "" MacOSX/Linux
""let g:ctrlp_custom_ignore = {
""    \ 'dir':  '\v[\/]\.$',
""    \ 'file': '\v\.$',
""    \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
""    \ }
let g:ctrlp_custom_ignore = {
   \ 'file': '\v\.'
    \ }
"" 在每次进行切换分支或者重新设定custome_ignore选项的时候,必须手动清除CtrlP的缓存,
"" 也可以使用下句不让它进行缓存处理,但扫描时间会比较耗时
""let g:ctrlp_use_caching = 0
let g:ctrlp_working_path_mode=0
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=15
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
nnoremap b :CtrlPBuffer
nnoremap d :CtrlPDir

""==============================================================
"" ctrlp-funky settings  ctrlp插件 - 不用ctag进行函数快速跳转
""==============================================================
""nnoremap fu :CtrlPFunky
nnoremap f :CtrlPFunky
"" narrow the list down with a word under cursor
""nnoremap fU :execute 'CtrlPFunky ' . expand
let g:ctrlp_funky_syntax_highlight = 1
let g:ctrlp_extensions = ['funky']

""==========================================
"" nerdcommenter settings  快速注释
""==========================================
"" 注释与代码之间留存的空格数
let g:NERDSpaceDelims = 1

""==========================================
"" Airline settings
""==========================================
""if !exists
""let g:airline_symbols = {}
""endif
""let g:airline_left_sep = '▶'
""let g:airline_left_alt_sep = '❯'
""let g:airline_right_sep = '◀'
""let g:airline_right_alt_sep = '❮'
""let g:airline_symbols.linenr = '¶'
""let g:airline_symbols.branch = '⎇'
"""" 开启tabline
""let g:airline#extensions#tabline#enabled = 1
"""" tabline中当前buffer两端的分隔符
""let g:airline#extensions#tabline#left_sep = ' '
"""" tabline为激活的buffer的两端字符
""let g:airline#extensions#tabline#left_alt_sep = '|'
"""" tabline中buffer显示编号
""let g:airline#extensions#tabline#buffer_nr_show = 1
""let g:airline#extensions#buffline#enabled = 1
""let g:airline#extensions#bufferline#overwrite_variables = 1
"""" airline主题
""let g:airline_theme = 'powerlineish' 

""括号显示增强
""let g:rbpt_colorpairs = [
""    \ ['brown',       'RoyalBlue3'],
""    \ ['Darkblue',    'SeaGreen3'],
""    \ ['darkgray',    'DarkOrchid3'],
""    \ ['darkgreen',   'firebrick3'],
""    \ ['darkcyan',    'RoyalBlue3'],
""    \ ['darkred',     'SeaGreen3'],
""    \ ['darkmagenta', 'DarkOrchid3'],
""    \ ['brown',       'firebrick3'],
""    \ ['gray',        'RoyalBlue3'],
""    \ ['black',       'SeaGreen3'],
""    \ ['darkmagenta', 'DarkOrchid3'],
""    \ ['Darkblue',    'firebrick3'],
""    \ ['darkgreen',   'RoyalBlue3'],
""    \ ['darkcyan',    'SeaGreen3'],
""    \ ['darkred',     'DarkOrchid3'],
""    \ ['red',         'firebrick3'],
""    \ ]
""let g:rbpt_max = 40
""let g:rbpt_loadcmd_toggle = 0
""au VimEnter * RainbowParenthesesToggle
""au Syntax * RainbowParenthesesLoadRound
""au Syntax * RainbowParenthesesLoadSquare
""au Syntax * RainbowParenthesesLoadBraces

""let g:solarized_termcolors=256
let g:solarized_termtrans=1

"" increase the width of the taglist window  
""let Tlist_WinWidth=20  
"" 自动打开TagList的window  
let Tlist_Auto_Open=0  
"" 当只剩下Tlist的时候自动关闭  
let Tlist_Exit_OnlyWindow=1  
"" 打开tags用单击  
let Tlist_Use_SingleClick=1  
"" close tag folders for inactive buffers  
let Tlist_File_Fold_Auto_Close=1  
"" show the fold indiactor column in the taglist window  
let Tlist_Enable_Fold_Column=1  
"" 自动更新TagList包含最新编辑的文件  
let Tlist_Auto_Update=1  
"" 显示一个文件的tag  
let Tlist_Show_One_File=1  
"" 在右侧显示窗口  
let Tlist_Use_Right_Window=1  
"" 让TagList始终解释文件中的tag,不管TagList窗口有没有打开  
let Tlist_Process_File_Always=1  
"" 将taglist与ctags关联
let Tlist_Ctags_Cmd="/usr/bin/ctags"
"" 设置leader键  
""" nnoremap tl :TlistToggle  
nnoremap  :TlistToggle

""let g:ycm_key_list_select_completion=['']
""let g:ycm_key_list_previous_completion=['']
let g:ycm_collect_indentifiers_from_tags_files=1  
let g:ycm_seed_identifiers_with_syntax=1  
"" 避免YCM每次加载都对用户提示是否加载  
let g:ycm_confirm_extra_conf=0  
let g:ycm_autoclose_preview_window_after_completion=1  

"" 设置NerdTree
map  :NERDTreeMirror
map  :NERDTreeToggle

" This tests to see if vim was configured with the '--enable-cscope' option
" when it was compiled.  If it wasn't, time to recompile vim...
if has("cscope")
    """"""""""""" Standard cscope/vim boilerplate

    " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
    set cscopetag

    " check cscope for definition of a symbol before checking ctags: set to 1
    " if you want the reverse search order.
    set csto=0

    " add any cscope database in current directory
    if filereadable("cscope.out")
        cs add cscope.out
    " else add the database pointed to by environment variable
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif

    " show msg when any other cscope db added
    set cscopeverbose


    """"""""""""" My cscope/vim key mappings
    "
    " The following maps all invoke one of the following cscope search types:
    "
    "   's'   symbol: find all references to the token under cursor
    "   'g'   global: find global definition(s) of the token under cursor
    "   'c'   calls:  find all calls to the function name under cursor
    "   't'   text:   find all instances of the text under cursor
    "   'e'   egrep:  egrep search for the word under cursor
    "   'f'   file:   open the filename under cursor
    "   'i'   includes: find files that include the filename under cursor
    "   'd'   called: find functions that function under cursor calls
    "
    " Below are three sets of the maps: one set that just jumps to your
    " search result, one that splits the existing vim window horizontally and
    " diplays your search result in the new window, and one that does the same
    " thing, but does a vertical split instead (vim 6 only).
    "
    " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
    " unlikely that you need their default mappings (CTRL-\'s default use is
    " as part of CTRL-\ CTRL-N typemap, which basically just does the same
    " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
    " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
    " of these maps to use other keys.  One likely candidate is 'CTRL-_'
    " (which also maps to CTRL-/, which is easier to type).  By default it is
    " used to switch between Hebrew and English keyboard mode.
    "
    " All of the maps involving the  macro use '^$': this is so
    " that searches over '#include " return only references to
    " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
    " files that contain 'time.h' as part of their name).


    " To do the first type of search, hit 'CTRL-\', followed by one of the
    " cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
    " search will be displayed in the current window.  You can use CTRL-T to
    " go back to where you were before the search.
    "

    nmap s :cs find s =expand("")
    nmap g :cs find g =expand("")
    " nmap    :cs find g =expand("")
    " imap  :cs find g =expand("")i
    nmap c :cs find c =expand("")
    nmap t :cs find t =expand("")
    " nmap    :cs find t =expand("")
    " imap  :cs find t =expand("")i
    nmap e :cs find e =expand("")
    nmap f :cs find f =expand("")
    nmap i :cs find i ^=expand("")$
    nmap d :cs find d =expand("")


    " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
    " makes the vim window split horizontally, with search result displayed in
    " the new window.
    "
    " (Note: earlier versions of vim may not have the :scs command, but it
    " can be simulated roughly via:
    "    nmap s  :cs find s =expand("")

    nmap s :scs find s =expand("")
    nmap g :scs find g =expand("")
    nmap c :scs find c =expand("")
    nmap t :scs find t =expand("")
    nmap e :scs find e =expand("")
    nmap f :scs find f =expand("")
    nmap i :scs find i ^=expand("")$
    nmap d :scs find d =expand("")


    " Hitting CTRL-space *twice* before the search type does a vertical
    " split instead of a horizontal one (vim 6 and up only)
    "
    " (Note: you may wish to put a 'set splitright' in your .vimrc
    " if you prefer the new window on the right instead of the left

    nmap s :vert scs find s =expand("")
    nmap g :vert scs find g =expand("")
    nmap c :vert scs find c =expand("")
    nmap t :vert scs find t =expand("")
    nmap e :vert scs find e =expand("")
    nmap f :vert scs find f =expand("")
    nmap i :vert scs find i ^=expand("")$
    nmap d :vert scs find d =expand("")


    """"""""""""" key map timeouts
    "
    " By default Vim will only wait 1 second for each keystroke in a mapping.
    " You may find that too short with the above typemaps.  If so, you should
    " either turn off mapping timeouts via 'notimeout'.
    "
    "set notimeout
    "
    " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
    " with your own personal favorite value (in milliseconds):
    "
    "set timeoutlen=4000
    "
    " Either way, since mapping timeout settings by default also set the
    " timeouts for multicharacter 'keys codes' (like ), you should also
    " set ttimeout and ttimeoutlen: otherwise, you will experience strange
    " delays as vim waits for a keystroke after you hit ESC (it will be
    " waiting to see if the ESC is actually part of a key code like ).
    "
    "set ttimeout
    "
    " personally, I find a tenth of a second to work well for key code
    " timeouts. If you experience problems and have a slow terminal or network
    " connection, set it higher.  If you don't set ttimeoutlen, the value for
    " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
    "
    "set ttimeoutlen=100

endif

转载于:https://www.cnblogs.com/jinliang-li/p/11393373.html

你可能感兴趣的:(开发工具,数据库,操作系统)