gvim usage

自动写入tile

autocmd BufNewFile *.py,*.pl exec ":call SetTitle()"
"新建python
"定义函数SetTitle,自动插入文件头
func SetTitle()  
    "如果文件类型为.python文件  
    if &filetype == 'python'  
        call setline(1, "\#!/usr/bin/env python")  
        call append(line("."), "\# -*- coding=utf8 -*-")  
    endif
    if &filetype == 'perl'  
        call setline(1, "\#!/usr/bin/env perl")  
        call append(line("."), "##################################")  
    endif    
    call append(line(".")+1, "\# Author: vinson")  
    call append(line(".")+2, "\# Created Time : ".strftime("%c"))  
    call append(line(".")+3, "\# File Name: ".expand("%"))  
    call append(line(".")+4, "\# Description:")  
    call append(line(".")+5, "##################################")  

endfunc 

comment:

  可以通过:set filetype 查看当前文件类型

匹配begin / end

可以先参看

runtime macros/matchit.vim

在.vimrc中添加

" Let the matchit plugin know what items can be matched.
"
runtime! macro/matchit.vim
if exists('loaded_matchit')
let b:match_ignorecase=0
let b:match_words=
  \ '\<begin\>:\<end\>,' .
  \ '\<if\>:\<else\>,' .
  \ '\<module\>:\<endmodule\>,' .
  \ '\<class\>:\<endclass\>,' .
  \ '\<program\>:\<endprogram\>,' .
  \ '\<clocking\>:\<endclocking\>,' .
  \ '\<property\>:\<endproperty\>,' .
  \ '\<sequence\>:\<endsequence\>,' .
  \ '\<package\>:\<endpackage\>,' .
  \ '\<covergroup\>:\<endgroup\>,' .
  \ '\<primitive\>:\<endprimitive\>,' .
  \ '\<specify\>:\<endspecify\>,' .
  \ '\<generate\>:\<endgenerate\>,' .
  \ '\<interface\>:\<endinterface\>,' .
  \ '\<function\>:\<endfunction\>,' .
  \ '\<task\>:\<endtask\>,' .
  \ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
  \ '\<fork\>:\<join\>\|\<join_any\>\|\<join_none\>,' .
  \ '`ifdef\>:`else\>:`endif\>,' .
  \ '\<generate\>:\<endgenerate\>,'
endif

systemverilog gvim 折叠

setlocal foldmethod=expr
set foldexpr=MyFoldExpr(v:lnum)
function! MyFoldExpr(line)
   let str = getline(a:line)   
   if str =~ '^\s*task\s' || str =~ '^\s*function\s'
      return 'a1'   
   elseif str =~ '^\s*endtask' || str =~ '^\s*endfunction'
      return 's1'
   elseif str=~'`uvm_\w*_utils_begin'
      return 'a1'   
   elseif str=~'`uvm_\w*_utils_end'
      return 's1'
   elseif str =~ '\sbegin\s*'
      return 'a2'
   elseif str =~ '\send\s*'
      return 's2'
   else
       return -1
   endif
endfunction

tab换成空格

set tabstop=2     " (ts) width (in spaces) that a <tab> is displayed as
set expandtab     " (et) expand tabs to spaces (use :retab to redo entire file)
set shiftwidth=2  " (sw) width (in spaces) used in each step of autoindent (aswell as << and >>)
set softtabstop=2

将之前的tab 也换成空格

在gvim上输入:retab !

.vimrc 常用配置

if has("syntax")
  syntax on
endif

if has("autocmd")
  filetype plugin indent on 
endif

augroup filetypedetect
  au! BufRead,BufNewFile *.v,*.vh,*.sa,*.sv,*.svh,*.svi set filetype=systemverilog
  au! BufRead,BufNewFile *.pl,*,pm setfiletype perl
  au! BufRead,BufNewFile *.py,*.pyc setfiletype python
augroup END

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd		" Show (partial) command in status line.
set showmatch		" Show matching brackets.
set ignorecase		" Do case insensitive matching
"set smartcase		" Do smart case matching
"set incsearch		" Incremental search
"set autowrite		" Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
set mouse=a		" Enable mouse usage (all modes)
set selection=exclusive
"set selection=mouse,key

"the below is my write 
set nu
"set autoindent
"set cindent
"set smartindent
set nocompatible
set background=light
set confirm          " need to confirm when save the read-only/no save file
set tabstop=4
set shiftwidth=4
"set expandtab
"set softtabstop=4
" :retab !
set hlsearch
set incsearch
set gdefault
set whichwrap+=<,>,h,l
set completeopt=preview,menu
runtime! ftplugin/matchit.vim
autocmd FileType systemverilog so ~/.vim/matchit/matchit_sv.vim
autocmd FileType systemverilog set tabstop=2 shiftwidth=2 expandtab


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  
" 一般设定  
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""  
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
colorscheme desert  
"colorscheme torte  
set guifont=Monospace\ 10
set clipboard+=unnamed 
syntax on

"syntax keyword gtkType gint gshort guint gushort gulong gdouble gfloat gchar guchar gboolean gpointer  
"highlight link gtkType Type  
highlight StatusLine guifg=SlateBlue guibg=Yellow  
highlight StatusLineNC guifg=Gray guibg=White 

set fillchars=vert:\ ,stl:\ ,stlnc:\

set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
  
set laststatus=2

" {{{ map keyword
inoremap ( ()<LEFT>
inoremap { {}<LEFT>
inoremap [ []<LEFT>
inoremap " ""<LEFT>

map <A-1> 1gt 
map <A-2> 2gt
map <A-3> 3gt
map <A-4> 4gt
map <A-5> 5gt
map <A-6> 6gt
map <A-7> 7gt
map <A-8> 8gt
map <A-9> 9gt
map <A-0> :tablast<CR>

map ww <Esc>:w<CR>
map qq <Esc>:q<CR>

" configuration vundle
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" }}}

"""""""""""""""""""""""""""""""""
" tags
"""""""""""""""""""""""""""""""""
source ~/vim_tag/vim_tag

"Let the matchit plugin know what items can be matched.
"must have the runtime xxx.vim
runtime! ftplugin/matchit.vim
if exists("loaded_matchit")
  let b:match_ignorecase=0
  let b:match_words=
        \ '\<begin\>:\<end\>,' .
        \ '\<if\>:\<else\>,' .
        \ '\<module\>:\<endmodule\>,' .
        \ '\<class\>:\<endclass\>,' .
        \ '\<program\>:\<endprogram\>,' .
        \ '\<clocking\>:\<endclocking\>,' .
        \ '\<property\>:\<endproperty\>,' .
        \ '\<sequence\>:\<endsequence\>,' .
        \ '\<package\>:\<endpackage\>,' .
        \ '\<covergroup\>:\<endgroup\>,' .
        \ '\<primitive\>:\<endprimitive\>,' .
        \ '\<specify\>:\<endspecify\>,' .
        \ '\<generate\>:\<endgenerate\>,' .
        \ '\<interface\>:\<endinterface\>,' .
        \ '\<function\>:\<endfunction\>,' .
        \ '\<task\>:\<endtask\>,' .
        \ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
        \ '\<fork\>:\<join\>\|\<join_any\>\|\<join_none\>,' .
        \ '`ifdef\>:`else\>:`endif\>,' .
        \ '\<generate\>:\<endgenerate\>'
endif		

快捷键

在文本中进入另一个文件(go to file)

gf: 直接进入文件

ctrl+w -> f:   sp出来一个一个窗口打开文件

ctrl+w ->g->f: 在另一个tab打开文件

tab切换

<A-1> 1gt 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值