分享

我的vim配置文件

 king5758 2017-05-24

"https://segmentfault.com/a/1190000005793581

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
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

set encoding=utf-8
lang messages zh_CN.UTF-8 

source $VIMRUNTIME/delmenu.vim   
source $VIMRUNTIME/menu.vim
set guifont=Source_Code_Pro:h12:cANSI

set nu

" 语法高亮
set syntax=enable 
set syntax=on

" 自动缩进
set autoindent
 
" C语言方式缩进
set cindent
 
" 智能缩进
set smartindent
 
" 统一缩进为4
set softtabstop=4
set shiftwidth=4

set showtabline=2

" 高亮显示匹配的括号
set showmatch
 
" 搜索逐字符高亮和实时搜索
set hlsearch
set incsearch
 
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5
 
" 显示括号配对情况
set showmatch
 
" 代码折叠
" set fdm=indent
 
" 选择代码折叠类型
set foldmethod=syntax
 
" 禁止自动折叠
set foldlevel=100
" 历史记录数
set history=1000
 
" 侦测文件类型
filetype on
 
" 为特定文件类型载入相关缩进格式
filetype indent on
 
" 为特定的文件类型载入对应的插件
filetype plugin on
filetype plugin indent on
 
" 不与vi兼容
set nocp

set nowrap

"winmanager设置
let g:winManagerWindowLayout='FileExplorer'
nmap wm :WMToggle<cr>

"NERD_commenter
let mapleader = ","

"  < txtbrowser 插件配置 >
" -----------------------------------------------------------------------------
" 用于文本文件生成标签与与语法高亮(调用TagList插件生成标签,如果可以)
au BufRead,BufNewFile *.txt setlocal ft=txt

" 自动切换目录为当前编辑文件所在目录
au BufRead,BufNewFile,BufEnter * cd %:p:h



au BufRead,BufNewFile *.svh set filetype=verilog_systemverilog
au BufRead,BufNewFile *.sv set filetype=verilog_systemverilog
au BufRead,BufNewFile *.v set filetype=verilog_systemverilog

vnoremap <S-Up>   gk
vnoremap <S-Down> gj
imap     <S-Up>   <Esc>gh<S-Up>
imap     <S-Down> <Esc><Right>gh<S-Down>
nmap     <S-Up>   gh<S-Up>
nmap     <S-Down> gh<S-Down>

" Use CTRL-S for saving, also in Insert mode
noremap <C-S>     <Esc>:update<CR>
"vnoremap <C-S>    <Esc>:update<CR>
inoremap <C-S>    <C-O>:update<CR>


set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码

" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed
" 设置 alt 键不映射到菜单栏
set winaltkeys=no

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG

" backspace and cursor keys wrap to previous/next line
set backspace=indent,eol,start whichwrap+=<,>,[,]

" backspace in Visual mode deletes selection
vnoremap <BS> d

" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x


" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y

" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O>u

" CTRL-Y is Redo (although not repeat); not in cmdline though
noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>


" CTRL-V and SHIFT-Insert are Paste
" map <C-V>   "+gP
map <S-Insert>    "+gP
cmap <S-Insert>   <C-R>+

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约