GVIM使用20200717zb

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

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 number
:set background=light
:set expandtab
set softtabstop=4
"set ignorecase
set shiftwidth=4
set tabstop=4

set nowritebackup
set nobackup
set directory=$VIMHOME\swp,.

set showcmd
set backspace=indent,eol,start
"set guifont=Courier\ 12\ Pitch
colorscheme darkblue

"消除文件格式不正确的出现^M
set fileformats=dos
"解决中文乱码--->
"set encoding=utf-8
"set termencoding=utf-8
set fileencodings=utf-8,chinese,latin-1

if has("win32")
    set fileencoding=chinese
else
    set fileencoding=utf-8
endif

"使用javacomplete插件
setlocal omnifunc=javacomplete#Complete
if has("autocmd")
  autocmd Filetype java setlocal omnifunc=javacomplete#Complete
endif
setlocal completefunc=javacomplete#CompleteParamsInfo


"language messages zh_CN.utf-8
"<---
"******************************************
"**************** IDE *********************
"******************************************
"creat tags
set tags=tags;
set autochdir
"let Tlist_Ctags_Cmd='/bin/ctags'  
"// 若在windows中应写成: let Tlist_Ctags_Cmd='ctags.exe' //注意ctags的环境变量设置
let Tlist_Ctags_Cmd='ctags.exe'
let Tlist_Show_One_File=1
let Tlist_OnlyWindow=1
let Tlist_Use_Right_Window=0
let Tlist_Sort_Type='name'
let Tlist_Exit_OnlyWindow=1
let Tlist_Show_Menu=1
let Tlist_Max_Submenu_Items=10
let Tlist_Max_Tag_length=20
let Tlist_Use_SingleClick=0
let Tlist_Auto_Open=0
let Tlist_Close_On_Select=0
let Tlist_File_Fold_Auto_Close=1
let Tlist_GainFocus_On_ToggleOpen=0
let Tlist_Process_File_Always=1
let Tlist_WinHeight=10
let Tlist_WinWidth=18
let Tlist_Use_Horiz_Window=0

"窗口管理
"let Tlist_Show_One_File=1
"let Tlist_Exit_OnlyWindow=1
"let g:winManagerWindowLayout='FileExplorer|TagList'
let g:winManagerWindowLayout='FileExplorer'
nmap vp :WMToggle<cr>
"多文件编辑
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplMapWindowsNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplorerMoreThanOne=1
"grep
nnoremap <silent> <F10> :Grep<CR>
"******************************************
"*********** edit myvim.vim ***************
"******************************************
:map <F11> :source $VIMHOME/_vimrc<cr>:w!<cr>
:map ,ee :e $VIMHOME/_vimrc<cr>
"******************************************
"*********** myvim.vim ********************
"******************************************
"开启选中即复制功能
"set guioptions+=a

"增加水平和垂直窗口
:map ;s :sp<cr>
:map ;v :vsplit<cr>

"例化光标选中变量
:map <F2> :call GetCursorPos()<cr>"ayiw^"byiw:call ShowInstance()<cr>@c:call cursor(b:cursor_line_new+1,b:cursor_col_new)<cr>
:map ;ex 0d$i<TAB>.<ESC>"ap8a<tab><ESC>a(<ESC>"ap8a<tab><ESC>a),<ESC>^28ldw28ldw
"生成当前时间
:imap <F2> <C-R>=strftime("%c")<CR>

"产生U_DLY
:imap <F4> <space><= #U_DLY

"产生头文件
:map <F5> 1GO<ESC>ggi
            \// *********************************************************************************/<cr><ESC>0d$i
            \// Project Name :<cr><ESC>0d$i
            \// Author       : XXXX<cr><ESC>0d$i
            \// Email        : XXXX@qq.com<cr><ESC>0d$i
            \// Creat Time   : <F2><cr><ESC>0d$i
            \// File Name    : .v<cr><ESC>0d$i
            \// Module Name  : <cr><ESC>0d$i
            \// Called By    : <cr><ESC>0d$i
            \// Abstract     : <cr><ESC>0d$i
            \//<cr><ESC>0d$i
            \// CopyRight(c) 2020, XXXX Technology Co., Ltd.. <cr><ESC>0d$i
            \// All Rights Reserved<cr><ESC>0d$i//<cr><ESC>0d$i
            \// *********************************************************************************/<cr><ESC>0d$i
            \// Modification History:<cr><ESC>0d$i
            \// 1. initial<cr><ESC>0d$i
            \// *********************************************************************************/<cr><ESC>0d$i
            \// *************************<cr><ESC>0d$i
            \// MODULE DEFINITION<cr><ESC>0d$i
            \// *************************<cr><ESC>0d$i
"            \`timescale 1 ns / 1 ns<cr><ESC>0d$i
"            \module #(<cr><ESC>0iparameter<tab><tab><tab><tab><tab><tab><tab>U_DLY = 1<cr>)<cr>(<cr><cr>);<cr>
"            \// Parameter Define <cr><ESC>0d$i
"            \<cr><ESC>0d$i
"            \// Register Define <cr><ESC>0d$i
"            \<cr><ESC>0d$i
"            \// Wire Define <cr><ESC>0d$i
"            \<cr><ESC>0d$i
"            \<cr><ESC>0d$i
"            \endmodule<ESC>9ki

"调整格式以便对齐(例化后的)
:map <F6> :.s/^ *\./    ./e<cr>:noh<cr>^f(i                              <ESC>f)i                               <ESC>^28ldw28ldwa  <ESC>hdwj

"添加注释
:vmap <F7> <ESC>:'<,'>s/^/\/\/<cr>:noh<cr>j
:nmap <F7> <ESC>:.s/^/\/\/<cr>:noh<cr>j
"删除注释
:vmap <F8> <ESC>:'<,'>s/^\/\///e<cr>:noh<cr>j
:nmap <F8> <ESC>:.s/^\/\///e<cr>:noh<cr>j

"删除TAB
:map ;t :%s/\t/    /g<cr>:noh<cr>
"删除

:map ;m :%s///g<cr>:noh<cr>

"重复上一个命令
:map ,, :<UP><cr>
"========================================================================================"
"   add the wire\reg\input\output
"========================================================================================"
:function! ShowWidth(...)
:    if(a:0 == 1)
:       if (a:1 >= 2)
:           let a:tmp = a:1 - 1
:           let @b = "[".a:tmp.":0]"
:       else
:           let @b = "     "
:       endif
:    else
:        let @b = "     "
:    endif
:endfunction

:command! -nargs=? OUTPUTR :normal :call ShowWidth(<f-args>)<cr>mx"ayiw0d$0ioutput<Tab>reg<Tab><Tab><Esc>"bp8a<Tab><Esc>"apa,<ESC>036ldw`xj
:command! -nargs=? OUTPUTW :normal :call ShowWidth(<f-args>)<cr>mx"ayiw0d$0ioutput<Tab>wire<Tab><Esc>"bp8a<Tab><Esc>"apa,<ESC>036ldw`xj
:command! -nargs=? INPUT  :normal :call ShowWidth(<f-args>)<cr>mx"ayiw0d$0iinput<Tab><Tab><Tab><Esc>"bp8a<Tab><Esc>"apa,<ESC>036ldw`xj
:command! -nargs=? REG    :normal :call ShowWidth(<f-args>)<cr>mx"ayiwgg:/^\/\/ Register Define\|^reg<cr>:/^\s*$<cr>:noh<cr>Oreg<Tab><Tab><Esc>"bp8a<Tab><Esc>"apa;<ESC>036ldw`xj
:command! -nargs=? WIRE   :normal :call ShowWidth(<f-args>)<cr>mx"ayiwgg:/^\/\/ Wire Define\|^wire<cr>:/^\s*$<cr>:noh<cr>Owire<Tab><ESC>"bp8a<Tab><Esc>"apa;<ESC>036ldw`xj

:map ;or :OUTPUTR
:map ;ow :OUTPUTW
:map ;i  :INPUT
:map ;r  :REG
:map ;w  :WIRE:

"生成always模板
:function! ShowClock(...)
:   if(a:0 == 1)
:       let @a = a:1
:       let @b = "rst_n"
:   elseif(a:0 == 2)
:       let @a = a:1
:       let @b = a:2
:   else
:       let @a = "clk"
:       let @b = "rst_n"
:   endif
:endfunction

:command! -nargs=* ALWAYS :normal :call ShowClock(<f-args>)<cr>
            \<ESC>0ialways @ (posedge <ESC>"apa or posedge <ESC>"bpa)begin<cr>
            \<ESC>0i
            \<ESC>0iend<ESC>O
            \<ESC>0i    if(<ESC>"bpa == 1'b0)<ESC>0dwi    <ESC>o
            \<ESC>0i    else    <ESC>o<ESC>2ko        <ESC>08l

:map ;al :ALWAYS

:map ;tt :Tlist

let b:cursor_line_old = 0
let b:cursor_col_old = 0
let b:cursor_line_new = 0
let b:cursor_col_new = 0
:function! GetCursorPos()
:   let b:cursor_line_old = line(".")
:   let b:cursor_col_old = col(".")
:endfunction

:function! ShowInstance()
:   let b:cursor_line_new = b:cursor_line_old
:   if @b != "//"
:       if(@a =~ '\a')
:           let b:cursor_col_new = b:cursor_col_old
:           let @c = ";ex"
:       else
:           let @c = ""
:       endif
:   else
:       let @c = ""
:   endif
:endfunction








一、说明

1、在环境变量中添加系统变量VIMHOME,变量值为_vimrc所在文件夹

 (如:“D:\Program Files (x86)\Vim”);

2、把plugin目录中的文件放在Vim安装目录下vim72文件夹中的plugin目录中;

3、vim72目录中的文件放在Vim安装目录下的vim72文件夹中;

4、在Vim安装目录下新建文件夹swp;

5、把_vimrc替换掉Vim安装目录下的_vimrc;

6、把_vimrc文件中105行167列的Author改为你自己的名字,把紧随其后的Email地址该为你自己的;

7、使用Tlist、ctags。 

 

二、快捷键使用说明:

快捷键名

使用模式

使用位置

功效

<F2>

Norm

需要例化的变量

把光标所在的变量进行例化,该行其余内容会被删除

<F2>

编辑

任何位置

生成当前时间

<F4>

编辑

变量后

在该变量后添加“ <= #U_DLY ”

<F5>

Norm

任何位置

在文档头部生成头文件

<F6>

Norm

任何位置

调整该行的格式,使其与变量例化后的格式同

<F7>

Norm

任何位置

添加注释

<F8>

Norm

任何位置

在reg、wire声明中使用,调整变量、逗号和注释的位置

<F9>

Norm

任何位置

同<F7>,适用于老版的module声明方式,即不包含input、output等关键字

<F10>

Norm

任何位置

进入搜索模式:默认是光标所在的变量,但是可以修改搜索值,支持正则表达式

;t

Norm

任何位置

删除TAB

;tt

Norm

任何位置

弹出Tlist

,,

Norm

任何位置

重复上一次命令

;ow

Norm

Model声明

声明接口变量 output wrie [参数-1:0] 变量名

;or

Norm

Model声明

声明接口变量 output reg  [参数-1:0] 变量名

;i

Norm

Model 声明

声明接口变量 input       [参数-1:0] 变量名

;r

Norm

变量

声明变量 reg  [参数-1:0] 变量名 

;w

Norm

变量

声明变量 wire  [参数-1:0] 变量名 

;al

Norm

任何位置

Always

vp

Norm

任何位置

在左侧显示文档所在目录

:v

Norm

任何位置

垂直分栏

:s

Norm

任何位置

水平分栏

x

Norm

任何位置

删除光标后续字符

dd

Norm

任何位置

删除行

三、其余功能:

1、程序中跳转

打开cmd命令行,切换到你要查看的源代码的根目录处,运行
ctags  -R
将会在此目录处生成一个tags文件。用gvim打开一个代码文件,将光标放到某一模块名上,按下"ctrl+]",光标会自动跳转到定义处。按下"ctrl+T"会跳回到原来的位置。

当你的源文件有更新时,只能重新运行ctags -R命令,来更新tags文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值