.vimrc

syntax on
filetype on
filetype indent on
filetype plugin on


"show line number 
set nu!


" expand tab with space
set expandtab


" tab stop at 4th space
set softtabstop=4
set shiftwidth=4


" ignorecase when search, equal to /\c
set ignorecase


set incsearch


" highlight search
set hls


" indent when typing
set autoindent


set guifont=LucidaTypewriter\ 14


" allow backspacing over everything in insert mode
set backspace=indent,eol,start


if (has("gui_running"))
"    set guifont=LucidaTypewriter\ 6


    "enable right click pop up menu
    set mousemodel=popup


    "enable bottom scrollbar
    set guioptions+=b


    "remove toolbar
    set guioptions-=T


    "wrap 
    set nowrap


    "set the color
    colorscheme evening
else
    set nowrap
    
    "colorscheme ron
endif


" let gvim more powerfull
set nocompatible


" show the row and column info 
set ruler




" Protect large files from sourcing and other overhead.
" Files become read only
if 1
    if !exists("my_auto_commands_loaded")
        let my_auto_commands_loaded = 1
        " Large files are > 10M
        " Set options:
        " eventignore+=FileType (no syntax highlighting etc
        " assumes FileType always on)
        " noswapfile (save copy of file)
        " bufhidden=unload (save memory when other file is viewed)
        " buftype=nowritefile (is read-only)
        " undolevels=-1 (no undo possible)
        let g:LargeFile = 1024 * 1024 * 10
        augroup LargeFile
        "autocmd BufReadPre * let f=expand("<afile>") | if getfsize(f) > g:LargeFile | set eventignore+=FileType | setlocal noswapfile bufhidden=unload buftype=acwrite undolevels=-1 | else | set eventignore-=FileType | endif
        augroup END
    endif
endif


"restore last cursor 
" Tell vim to remember certain things when we exit
"  '10 : marks will be remembered for up to 10 previously edited files
"  "100 : will save up to 100 lines for each register
"  :20 : up to 20 lines of command-line history will be remembered
"  % : saves and restores the buffer list
"  n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo


" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
    au!
    autocmd BufReadPost *
                \ if expand("<afile>:p:h") !=? $TEMP |
                \ if line("'\"") > 1 && line("'\"") <= line("$") |
                \ let JumpCursorOnEdit_foo = line("'\"") |
                \ let b:doopenfold = 1 |
                \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
                \ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
                \ let b:doopenfold = 2 |
                \ endif |
                \ exe JumpCursorOnEdit_foo |
                \ endif |
                \ endif
    " Need to postpone using "zv" until after reading the modelines.
    autocmd BufWinEnter *
                \ if exists("b:doopenfold") |
                \ exe "normal zv" |
                \ if(b:doopenfold > 1) |
                \ exe "+".1 |
                \ endif |
                \ unlet b:doopenfold |
                \ endif
augroup END




" ----- Emulate 'gf' but recognize :|, line format -----
if 1
    function! GotoFile(w,m)
        if a:m == "v"
            let curword = GetVisual()
        else
            let curword = expand("<cfile>")
        endif
        if (strlen(curword) == 0)
            return
        endif
        let matchstart = match(curword, '[:|,]\d\+$')
        if matchstart > 0
            let pos = '+' . strpart(curword, matchstart+1)
            let fname = strpart(curword, 0, matchstart)
        else
            let pos = ""
            let fname = curword
        endif
        " Open new window if requested
        if a:w == "new"
            new
        endif
        " Use 'find' so path is searched like 'gf' would
        execute 'find ' . pos . ' ' . fname
    endfunction
    function! GetVisual() range
        let reg_save = getreg('"')
        let regtype_save = getregtype('"')
        let cb_save = &clipboard
        set clipboard&
        normal! ""gvy
        let selection = getreg('"')
        call setreg('"', reg_save, regtype_save)
        let &clipboard = cb_save
        return selection
    endfunction




    set isfname+=: " include colon in filenames


    " Override vim commands 'gf', '^Wf', '^W^F'
    nnoremap gf :call GotoFile("","")<CR>
    nnoremap <C-W>f :call GotoFile("new","")<CR>
    nnoremap <C-W><C-F> :call GotoFile("new","")<CR>
    vnoremap gf :call GotoFile("", "v")<CR>
endif




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" below is not necessary                                                    "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
":fixdel


"No attention message 
set shortmess+=A


" double click to search
 noremap <2-LeftMouse> :let @/="\\<".expand("<cword>")."\\>"<CR>:set hlsearch<CR>


" p4 open current file by type PfOpen command in vim
" it is the same as !p4 open %
:command! -nargs=0 PfOpen :exe "!p4 open "expand("%")


" from module to instance
noremap <F2> : s/\(\w\w*\)\(,*.*\)\s*$/\.\1(\1)\2/g <CR> : nohl <CR>


" Ctrl+C to comment or uncomment
"noremap <C-C> :call Comment() <CR> j
"function! Comment()
"    let l = getline(".")
"    if l =~ '^\s*\/\/'
"        :s/^\(\s*\)\/\//\1/
"    else
"        ":s/^\(\s*\)\(\w*\)/\1\/\/\2/
"        :s/.*/\/\/&/g
"    endif
"endfunction




"colorscheme murphy
"map <C-LeftMouse> to g] for ctags default tlist behavior
"noremap <C-LeftMouse> g]
"
"set statusline=[%02n]\ %f 
"set nolist
"set of auto line break
"set linebreak
" set which key can move line at begin or end of a line
" set whichwrap=b,s,<,>,[,]


" verilog indent, need a local indent file to work properly
au BufReadPost * if exists("b:current_syntax")
au BufReadPost *   if b:current_syntax == "verilog"
au BufReadPost *     let b:verilog_indent_modules = 1
au BufReadPost *   endif
au BufReadPost * endif


"auto insert template
function SetTitle()
    "jump to head of the file
    autocmd BufNewFile * normal gg
    
    if &filetype == 'perl'
        "remove the original head
        autocmd BufNewFile * normal 36dd
        call setline(1,"#! /usr/bin/perl")
        call setline(2,"# ---------------------------------------------------------------------")
        call setline(3,"# FILE NAME    : ")
        call setline(4,"# TYPE         : ")
        call setline(5,"# AUTHOR       :  ")
        call setline(6,"# EMAIL        :.com")
        call setline(7,"# ---------------------------------------------------------------------")
        call setline(8,"#")
        call setline(9,"# Release history")
        call setline(10,"# VERSION DATE AUTHOR DESCRIPTION")
        call setline(11,"# KEYWORD      : ")
        call setline(12,"# PURPOSE      : ")
        call setline(13,"# Created Time : ".strftime("%c"))
        call setline(14,"#")
        call setline(15,"# ---------------------------------------------------------------------")
    else
        if &filetype == 'verilog'
            "remove the original head
            autocmd BufNewFile * normal 29dd
            call setline(1,"// ---------------------------------------------------------------------")
            call setline(2,"// FILE NAME    : ")
            call setline(3,"// TYPE         : ")
            call setline(4,"// AUTHOR       :  ")
            call setline(5,"// EMAIL        : com")
            call setline(6,"// ---------------------------------------------------------------------")
            call setline(7,"//")
            call setline(8,"// Release history")
            call setline(9,"// VERSION DATE AUTHOR DESCRIPTION")
            call setline(10,"// KEYWORD      : ")
            call setline(11,"// PURPOSE      : ")
            call setline(12,"// Created Time : ".strftime("%c"))
            call setline(13,"//")
            call setline(14,"// ---------------------------------------------------------------------")
        else
            call setline(1,"// ---------------------------------------------------------------------")
            call setline(2,"// FILE NAME    : ")
            call setline(3,"// TYPE         : ")
            call setline(4,"// AUTHOR       :  ")
            call setline(5,"// EMAIL        : .com")
            call setline(6,"// ---------------------------------------------------------------------")
            call setline(7,"//")
            call setline(8,"// Release history")
            call setline(9,"// VERSION DATE AUTHOR DESCRIPTION")
            call setline(10,"// KEYWORD      : ")
            call setline(11,"// PURPOSE      : ")
            call setline(12,"// Created Time : ".strftime("%c"))
            call setline(13,"//")
            call setline(14,"// ---------------------------------------------------------------------")
        endif
        if &filetype == 'c' || &filetype == 'cpp' || &filetype == 'cc'
            call setline(1,"#include <iostream>")
            call setline(2,"using namespace std;")
            call setline(3,"                    ")
            call setline(4,"// AUTHOR       : ")
            call setline(5,"// EMAIL        : .com")
            call setline(6,"// ---------------------------------------------------------------------")
            call setline(7,"//")
            call setline(8,"// Release history")
            call setline(9,"// VERSION DATE AUTHOR DESCRIPTION")
            call setline(10,"// KEYWORD      : ")
            call setline(11,"// PURPOSE      : ")
            call setline(12,"// Created Time : ".strftime("%c"))
            call setline(13,"//")
            call setline(14,"// ---------------------------------------------------------------------")
        endif
    endif
endfunction
autocmd BufNewFile *.pl,*.sv,*.v,*.c,*.cpp,*.c: call SetTitle() 


"@m insert FF_DLY
let @m = "i#`FF_DLY "


"@c insert #!/bin/csh -f
let @c = "i#!/bin/csh -f"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值