现在的位置: 首页 > 综合 > 正文

vim 配置

2018年04月10日 ⁄ 综合 ⁄ 共 2566字 ⁄ 字号 评论关闭

vim配置文件存放位置:

windows:修改安装目录下的_vimrc文件(在别到地方编辑,然后copy替换该文件)

Linux:

vim初始配置文件位置“~/.vimrc”

一般vim会有一个默认的配置文件样本.cp到用户目录中,"cp /usr/share/vim/vim73/vimrc_example.vim ~/.vimrc"

然后追加下面自定义设置.

以下是自定义内容,当作备份

具体参数含义参见vim帮助文档

eg: ”:help smarttab“

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

"set directory to save backup files
"set backup 
"set writebackup 
"set backupdir=C:\BackUp\VimBKFiles

"not use tool bar, to make code area larger
set guioptions-=T
"set GVim window to max size when setup
au GUIEnter * simalt ~x

"tab = 4
set smarttab
set tabstop=4
set shiftwidth=4
"use space instead of tab
set expandtab

:set cursorline

let Tlist_Ctags_Cmd="ctags.exe"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
"let Tlist_Auto_Open=1
let Tlist_Sort_Type="name"
let Tlist_Use_Right_Window=1
let Tlist_Inc_Winwidth=0
let Tlist_WinWidth=40
"let ctags_cmd = '"' . ctags_cmd . '"'

"let g:winManagerWindowLayout= "FileExplorer"
let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer'
"let g:winManagerWindowLayout='NERDTree'
let g:winManagerWidth = 40

nmap <F2> <esc>:nohlsearch<cr>
nmap <F3> <esc>:cn<cr>
nmap <F4> <esc>:cp<cr>
map <F6> <esc>:%!xxd -g 1<cr>
"map <F7> <esc>:NERDTreeToggle<cr>
map <F7> <esc>:WMToggle<cr>
map <F8> <esc>:Tlist<cr>

map <F9> <esc>:set tags=tags<cr>

"F10与ubuntu系统快捷键冲突, 所以用组合键Ctrl+F10

map <C-F10> <esc>:!ctags -R<cr>

"F1建和帮助快捷键冲突,Ctrl+F1和vim终端快捷键冲突,所以用Ctrl+F5组合键插入时间信息

imap <C-F5> <C-R>=strftime("%Y-%m-%d")<CR>

let g:miniBufExplMapWindowNavVim    = 1 
let g:miniBufExplMapWindowNavArrows = 1 
let g:miniBufExplMapCTabSwitchBufs  = 1 
let g:miniBufExplModSelTarget       = 1 

set nu
"colorscheme default

"关闭声音提示

set noeb

set vb t_vb=

"关闭可视的错误提示
set vb t_vb=

"NERDTree只显示.h .c .cc .cpp等头文件和源文件

let NERDTreeIgnore=['\w*[^hcpy]$', '[^\.]\(h\|[^\.]c\|..p\|.y\)$','\.[^c]c',  '\..[^p]p$', '\.[^c]pp$', '\.[^p]y']

"重命名文件,自定命令为Rename,修改当前编辑文件的名字,eg. ":Rename newName.java"

:command! -nargs=1 Rename let tpname = expand('%:t') | saveas <args> | edit <args> | call delete(expand(tpname))

参考资料:

1· http://www.xxlinux.com/linux/article/accidence/technique/20071214/13341.html

2· http://yuxu9710108.blog.163.com/blog/static/237515342010102532414570/

抱歉!评论已关闭.