高效率办公的vim配置

filetype on
syntax   on
filetype plugin on
filetype indent on

set nocp

set nocompatible
"colorscheme koehler
"colorscheme desert
colorscheme darkblue_my
set noswapfile

set cursorline
set cursorcolumn
"--- show line number
set nu
set relativenumber

"--- tab to 4 space
set ts=4
set expandtab

set so=3

"--- Auto indent
set autoindent

"--- Search
set incsearch

set wildmode=longest,list

set gfn=Monospace\ 11

if has("gui_running")
  set lines=999
  set columns=999
endif

nmap <C-j> <C-W>j
nmap <C-k> <C-W>k
nmap <C-h> <C-W>h
nmap <C-l> <C-W>l

nnoremap ; :
nnoremap ' ;

inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i

set foldmethod=syntax

""--- Set netrw
"let g:netrw_banner = 0
"let g:netrw_liststyle = 3
"let g:netrw_browser_split = 2
"let g:netrw_altv = 1
"let g:netrw_winsize = 25
"augroup ProjectDrawer
"  autocmd!
"  autocmd VimEnter * :Vexplore
"augroup END
"




" /usr/share/vim/vim70/filetype.vim
" Verilog HDL
au BufNewFile,BufRead *.v,*.vg,*.vh setf verilog
au BufNewFile,BufRead *.sv,*.svh    setf systemverilog
au BufNewFile,BufRead *.xdc,*.sdc   setf tcl
au BufNewFile,BufRead *.md          setf markdown

"--- add verilog commment
:map <C-c> <C-V><HOME>I// <ESC>
"--- remove verilog commment
:map <C-n> <C-V><HOME><RIGHT><RIGHT>x<ESC>
   
""""""""""""""""""""""""""""""
" NERDTree setting
""""""""""""""""""""""""""""""
let NERDTreeDirArrows = 0
nmap <silent> <leader>tg :NERDTreeToggle<cr>
nmap <silent> <leader>e. :e %:p:h<cr>
map <M-a> <Esc>:NERDTree<cr>


"--- merge multi-line sdc to one line
":map <C-m> <ESC>:%s/\s\+\\\n/ /g

"--- tab switch ALT+, ALT+.
:map <M-j> gT
:map <M-k> gt

source ~/.vim/verilog_emacsauto.vim


:cmap te tabedit 
:cmap tn tabnew 

:cmap al Align 

:cmap hex %!xxd


" matchit.vim config for verilog
let b:match_words='\<begin\>:\<end\>'
let b:match_words='\<function\>:\<endfunction\>'
let b:match_words='\<module\>:\<endmodule\>'
let b:match_words='\<class\>:\<endclass\>'
let b:match_words='\<task\>:\<endtask\>'
let b:match_words='\<generate\>:\<endgenerate\>'




""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" verilog code block
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:ab fg- //-------------------------------------------------------------------------------------------
:ab fg= //===========================================================================================
:ab alwc   always @(*) begin<Enter><Enter>end
:ab alws   always @(posedge clk or negedge rst_n) begin <Enter>if(!rst_n) begin <Enter><= 'h0;<Enter>end else if() begin<Enter><= ;<Enter>end <Enter>end<ESC>4kf<hi
:ab alwcc  always @(*) begin<Enter>case()<Enter>default :<Enter>endcase<Enter>end
:ab alwsc  always @(posedge clk) begin<Enter>if(!rst_n) begin <Enter><= 0;<Enter>end else case()<Enter>default :<Enter>endcase<Enter>end
:ab alwac  always @(posedge clk or negedge rst_n) begin<Enter>if(!rst_n) begin <Enter><= 0;<Enter>end else case()<Enter>default :<Enter>endcase<Enter>end
:ab inw    input  wire
:ab opw    output wire
:ab opr    output reg 
:ab begin  begin<Enter>end<Esc>k$a
:ab generate generate<Enter>endgenerate<Esc>k$a
:ab module module<Enter><Enter>endmodule<Esc>2k$a

:ab ndef   `ifndef INC_SV__ <Enter>`define INC_SV__<Enter><Enter>`endif<ESC>2k
:ab class  class<Enter>endclass<ESC>k$a
:ab clse   class extends ;<Enter>endclass:<ESC>k
:ab func   function<Enter>endfunction<ESC>k$a
:ab vfunc  extern virtual function ();<ESC>
:ab task   task<Enter>endtask<ESC>k$a
:ab vtsk   extern virtual task();<ESC>F(a


autocmd BufNewFile *.v,*.sv,*.vh,*.svh exec ":call SetHeaderDescription()"
function SetHeaderDescription()
    call setline(1           , "//+FHDR*************************************************************************")
    call append (line(".")   , "// ")
    call append (line(".")+1 , "//   Copyright (c) ")
    call append (line(".")+2 , "// ")
    call append (line(".")+3 , "//   THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ")
    call append (line(".")+4 , "//   The copyright notice above does not evidence any actual or intended")
    call append (line(".")+5 , "//   publication of such source code.")
    call append (line(".")+6 , "// ")
    call append (line(".")+7 , "//************************************************************************")
    call append (line(".")+8 , "//    Module name: ".expand("%"))
    call append (line(".")+9 , "//    Create by  : lihua")
    call append (line(".")+10, "//    Email      : lihua@qq.com")
    call append (line(".")+11, "//    Create time: ".strftime("%Y_%m_%d"))
    call append (line(".")+12, "//************************************************************************")
    call append (line(".")+13, "//    Change List:")
    call append (line(".")+14, "//    ".strftime("%Y-%m-%d")." lihua: initial version")
    call append (line(".")+15, "//************************************************************************")
    call append (line(".")+16, "//    Module Function Description:")
    call append (line(".")+17, "//    This module ")
    call append (line(".")+18, "//-FHDR*************************************************************************")

    normal G
endfunction
" Vim filetype plugin for using emacs verilog-mode
" Last Change: 2007 August 29
" License:     This file is placed in the public domain.

" comment out these two lines
" if you don't want folding or if you prefer other folding methods
setlocal foldmethod=expr
setlocal foldexpr=VerilogEmacsAutoFoldLevel(v:lnum)

if exists("loaded_verilog_emacsauto")
   finish
endif
let loaded_verilog_emacsauto = 1

" map \a, \d pair to Add and Delete functions, assuming \ is the leader
" alternatively, map C-A, C-D to Add and Delete functions
if !hasmapto('<Plug>VerilogEmacsAutoAdd')
   map <unique> <Leader>a <Plug>VerilogEmacsAutoAdd
   "map <unique> <C-A> <Plug>VerilogEmacsAutoAdd
endif
if !hasmapto('<Plug>VerilogEmacsAutoDelete')
   map <unique> <Leader>d <Plug>VerilogEmacsAutoDelete
   "map <unique> <C-D> <Plug>VerilogEmacsAutoDelete
endif

noremap <unique> <script> <Plug>VerilogEmacsAutoAdd    <SID>Add
noremap <unique> <script> <Plug>VerilogEmacsAutoDelete <SID>Delete
noremap <SID>Add    :call <SID>Add()<CR>
noremap <SID>Delete :call <SID>Delete()<CR>
" add menu items for gvim
noremenu <script> Plugin.Verilog\ AddAuto    <SID>Add
noremenu <script> Plugin.Verilog\ DeleteAuto <SID>Delete

" Add function
" saves current document to a temporary file
" runs the temporary file through emacs
" replaces current document with the emacs filtered temporary file
" removes temporary file
" also replaces emacs generated tabs with spaces if expandtab is set
" comment out the two if blocks to leave the tabs alone
function s:Add()
   if &expandtab
      let s:save_tabstop = &tabstop
      let &tabstop=8
   endif
   " a tmp file is need 'cause emacs doesn't support the stdin to stdout flow
   " maybe add /tmp to the temporary filename
   w! %.emacsautotmp
   !emacs -batch -l ~/.vim/elisp/verilog-mode.el %.emacsautotmp -f verilog-batch-auto
   %!cat %.emacsautotmp 
   if &expandtab
      retab
      let &tabstop=s:save_tabstop
   endif
   !rm %.emacsautotmp -rf
endfunction

" Delete function
" saves current document to a temporary file
" runs the temporary file through emacs
" replaces current document with the emacs filtered temporary file
" removes temporary file
function s:Delete()
   " a tmp file is need 'cause emacs doesn't support the stdin to stdout flow
   " maybe add /tmp to the temporary filename
   w! %.emacsautotmp
   !emacs -batch -l ~/.vim/elisp/verilog-mode.el %.emacsautotmp -f verilog-batch-delete-auto
   %!cat %.emacsautotmp 
   !rm %.emacsautotmp
endfunction

""  " VerilogEmacsAutoFoldLevel function
""  " only deals with 0 and 1 levels
""  function VerilogEmacsAutoFoldLevel(l)
""     if (getline(a:l-1)=~'\/\*A\S*\*\/' && getline(a:l)=~'\/\/ \(Outputs\|Inputs\|Inouts\|Beginning\)')
""        return 1
""     endif
""     if (getline(a:l-1)=~'\(End of automatics\|);\)')
""        return 0
""     endif
""     return '='
""  endfunction

.vimrc配置

verilog_emacsauto.vim

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值