<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 189,comments - 115,trackbacks - 0
    vim 配置文件 ,高亮+自動縮進+行號+折疊+優化
    http://apps.hi.baidu.com/share/detail/31767352
    將一下代碼copy到 用戶目錄下 新建文件為  .vimrc
    保存即可生效; 如果想所有用戶生效 請修改 /etc/vimrc (建議先cp一份)
    "=========================================================================
    " DesCRiption: 適合自己使用的vimrc文件,for Linux/Windows, GUI/Console
    "
    " Last Change: 2010年08月02日 15時13分
    "
    " Version: 1.80
    "
    "=========================================================================

    set nocompatible " 關閉 vi 兼容模式
    syntax on " 自動語法高亮
    colorscheme molokai " 設定配色方案
    set number " 顯示行號
    set cursorline " 突出顯示當前行
    set ruler " 打開狀態欄標尺
    set shiftwidth=4 " 設定 << 和 >> 命令移動時的寬度為 4
    set softtabstop=4 " 使得按退格鍵時可以一次刪掉 4 個空格
    set tabstop=4 " 設定 tab 長度為 4
    set nobackup " 覆蓋文件時不備份
    set autochdir " 自動切換當前目錄為當前文件所在的目錄
    filetype plugin indent on " 開啟插件
    set backupcopy=yes " 設置備份時的行為為覆蓋
    set ignorecase smartcase " 搜索時忽略大小寫,但在有一個或以上大寫字母時仍保持對大小寫敏感
    set nowrapscan " 禁止在搜索到文件兩端時重新搜索
    set incsearch " 輸入搜索內容時就顯示搜索結果
    set hlsearch " 搜索時高亮顯示被找到的文本
    set noerrorbells " 關閉錯誤信息響鈴
    set novisualbell " 關閉使用可視響鈴代替呼叫
    set t_vb= " 置空錯誤鈴聲的終端代碼
    " set showmatch " 插入括號時,短暫地跳轉到匹配的對應括號
    " set matchtime=2 " 短暫跳轉到匹配括號的時間
    set magic " 設置魔術
    set hidden " 允許在有未保存的修改時切換緩沖區,此時的修改由 vim 負責保存
    set guioptions-=T " 隱藏工具欄
    set guioptions-=m " 隱藏菜單欄
    set smartindent " 開啟新行時使用智能自動縮進
    set backspace=indent,eol,start
    " 不設定在插入狀態無法用退格鍵和 Delete 鍵刪除回車符
    set cmdheight=1 " 設定命令行的行數為 1
    set laststatus=2 " 顯示狀態欄 (默認值為 1, 無法顯示狀態欄)
    set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
    " 設置在狀態行顯示的信息
    set foldenable " 開始折疊
    set foldmethod=syntax " 設置語法折疊
    set foldcolumn=0 " 設置折疊區域的寬度
    setlocal foldlevel=1 " 設置折疊層數為
    " set foldclose=all " 設置為自動關閉折疊
    " nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
    " 用空格鍵來開關折疊


    " return OS type, eg: windows, or linux, mac, et.st..
    function! MySys()
    if has("win16") || has("win32") || has("win64") || has("win95")
    return "windows"
    elseif has("unix")
    return "linux"
    endif
    endfunction

    " 用戶目錄變量$VIMFILES
    if MySys() == "windows"
    let $VIMFILES = $VIM.'/vimfiles'
    elseif MySys() == "linux"
    let $VIMFILES = $HOME.'/.vim'
    endif

    " 設定doc文檔目錄
    let helptags=$VIMFILES.'/doc'

    " 設置字體 以及中文支持
    if has("win32")
    set guifont=Inconsolata:h12:cANSI
    endif

    " 配置多語言環境
    if has("multi_byte")
    " UTF-8 編碼
    set encoding=utf-8
    set termencoding=utf-8
    set formatoptions+=mM
    set fencs=utf-8,gbk

    if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
    set ambiwidth=double
    endif

    if has("win32")
    source $VIMRUNTIME/delmenu.vim
    source $VIMRUNTIME/menu.vim
    language messages zh_CN.utf-8
    endif
    else
    echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
    endif

    " Buffers操作快捷方式!
    nnoremap <C-RETURN> :bnext<CR>
    nnoremap <C-S-RETURN> :bprevious<CR>

    " Tab操作快捷方式!
    nnoremap <C-TAB> :tabnext<CR>
    nnoremap <C-S-TAB> :tabprev<CR>

    "關于tab的快捷鍵
    " map tn :tabnext<cr>
    " map tp :tabprevious<cr>
    " map td :tabnew .<cr>
    " map te :tabedit
    " map tc :tabclose<cr>

    "窗口分割時,進行切換的按鍵熱鍵需要連接兩次,比如從下方窗口移動
    "光標到上方窗口,需要<c-w><c-w>k,非常麻煩,現在重映射為<c-k>,切換的
    "時候會變得非常方便.
    nnoremap <C-h> <C-w>h
    nnoremap <C-j> <C-w>j
    nnoremap <C-k> <C-w>k
    nnoremap <C-l> <C-w>l

    "一些不錯的映射轉換語法(如果在一個文件中混合了不同語言時有用)
    nnoremap <leader>1 :set filetype=xhtml<CR>
    nnoremap <leader>2 :set filetype=css<CR>
    nnoremap <leader>3 :set filetype=javascript<CR>
    nnoremap <leader>4 :set filetype=php<CR>

    " set fileformats=unix,dos,mac
    " nmap <leader>fd :se fileformat=dos<CR>
    " nmap <leader>fu :se fileformat=unix<CR>

    " use Ctrl+[l|n|p|cc] to list|next|previous|jump to count the result
    " map <C-x>l <ESC>:cl<CR>
    " map <C-x>n <ESC>:cn<CR>
    " map <C-x>p <ESC>:cp<CR>
    " map <C-x>c <ESC>:cc<CR>


    " 讓 Tohtml 產生有 CSS 語法的 html
    " syntax/2html.vim,可以用:runtime! syntax/2html.vim
    let html_use_css=1

    " Python 文件的一般設置,比如不要 tab 等
    autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
    autocmd FileType python map <F12> :!python %<CR>

    " 選中狀態下 Ctrl+c 復制
    vmap <C-c> "+y

    " 打開javascript折疊
    let b:javascript_fold=1
    " 打開javascript對dom、html和css的支持
    let javascript_enable_domhtmlcss=1
    " 設置字典 ~/.vim/dict/文件的路徑
    autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict
    autocmd filetype css set dictionary=$VIMFILES/dict/css.dict
    autocmd filetype php set dictionary=$VIMFILES/dict/php.dict

    "-----------------------------------------------------------------
    " plugin - bufexplorer.vim Buffers切換
    " \be 全屏方式查看全部打開的文件列表
    " \bv 左右方式查看 \bs 上下方式查看
    "-----------------------------------------------------------------


    "-----------------------------------------------------------------
    " plugin - taglist.vim 查看函數列表,需要ctags程序
    " F4 打開隱藏taglist窗口
    "-----------------------------------------------------------------
    if MySys() == "windows" " 設定windows系統中ctags程序的位置
    let Tlist_Ctags_Cmd = '"'.$VIMRUNTIME.'/ctags.exe"'
    elseif MySys() == "linux" " 設定windows系統中ctags程序的位置
    let Tlist_Ctags_Cmd = '/usr/bin/ctags'
    endif
    nnoremap <silent><F4> :TlistToggle<CR>
    let Tlist_Show_One_File = 1 " 不同時顯示多個文件的tag,只顯示當前文件的
    let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一個窗口,則退出vim
    let Tlist_Use_Right_Window = 1 " 在右側窗口中顯示taglist窗口
    let Tlist_File_Fold_Auto_Close=1 " 自動折疊當前非編輯文件的方法列表
    let Tlist_Auto_Open = 0
    let Tlist_Auto_Update = 1
    let Tlist_Hightlight_Tag_On_BufEnter = 1
    let Tlist_Enable_Fold_Column = 0
    let Tlist_Process_File_Always = 1
    let Tlist_Display_Prototype = 0
    let Tlist_Compact_Format = 1


    "-----------------------------------------------------------------
    " plugin - mark.vim 給各種tags標記不同的顏色,便于觀看調式的插件。
    " \m mark or unmark the word under (or before) the cursor
    " \r manually input a regular expression. 用于搜索.
    " \n clear this mark (i.e. the mark under the cursor), or clear all highlighted marks .
    " \* 當前MarkWord的下一個 \# 當前MarkWord的上一個
    " \/ 所有MarkWords的下一個 \? 所有MarkWords的上一個
    "-----------------------------------------------------------------


    "-----------------------------------------------------------------
    " plugin - NERD_tree.vim 以樹狀方式瀏覽系統中的文件和目錄
    " :ERDtree 打開NERD_tree :NERDtreeClose 關閉NERD_tree
    " o 打開關閉文件或者目錄 t 在標簽頁中打開
    " T 在后臺標簽頁中打開 ! 執行此文件
    " p 到上層目錄 P 到根目錄
    " K 到第一個節點 J 到最后一個節點
    " u 打開上層目錄 m 顯示文件系統菜單(添加、刪除、移動操作)
    " r 遞歸刷新當前目錄 R 遞歸刷新當前根目錄
    "-----------------------------------------------------------------
    " F3 NERDTree 切換
    map <F3> :NERDTreeToggle<CR>
    imap <F3> <ESC>:NERDTreeToggle<CR>


    "-----------------------------------------------------------------
    " plugin - NERD_commenter.vim 注釋代碼用的,
    " [count],cc 光標以下count行逐行添加注釋(7,cc)
    " [count],cu 光標以下count行逐行取消注釋(7,cu)
    " [count],cm 光標以下count行嘗試添加塊注釋(7,cm)
    " ,cA 在行尾插入 /* */,并且進入插入模式。 這個命令方便寫注釋。
    " 注:count參數可選,無則默認為選中行或當前行
    "-----------------------------------------------------------------
    let NERDSpaceDelims=1 " 讓注釋符與語句之間留一個空格
    let NERDCompactSexyComs=1 " 多行注釋時樣子更好看


    "-----------------------------------------------------------------
    " plugin - DoxygenToolkit.vim 由注釋生成文檔,并且能夠快速生成函數標準注釋
    "-----------------------------------------------------------------
    let g:DoxygenToolkit_authorName="Asins - asinsimple AT gmail DOT com"
    let g:DoxygenToolkit_briefTag_funcName="yes"
    map <leader>da :DoxAuthor<CR>
    map <leader>df :Dox<CR>
    map <leader>db :DoxBlock<CR>
    map <leader>dc a /* */<LEFT><LEFT><LEFT>


    "-----------------------------------------------------------------
    " plugin – ZenCoding.vim 很酷的插件,HTML代碼生成
    " 插件最新版:http://github.com/mattn/zencoding-vim
    " 常用命令可看:http://nootn.com/blog/Tool/23/
    "-----------------------------------------------------------------


    "-----------------------------------------------------------------
    " plugin – checksyntax.vim JavaScript常見語法錯誤檢查
    " 默認快捷方式為 F5
    "-----------------------------------------------------------------
    let g:checksyntax_auto = 0 " 不自動檢查


    "-----------------------------------------------------------------
    " plugin - NeoComplCache.vim 自動補全插件
    "-----------------------------------------------------------------
    let g:AutoComplPop_NotEnableAtStartup = 1
    let g:NeoComplCache_EnableAtStartup = 1
    let g:NeoComplCache_SmartCase = 1
    let g:NeoComplCache_TagsAutoUpdate = 1
    let g:NeoComplCache_EnableInfo = 1
    let g:NeoComplCache_EnableCamelCaseCompletion = 1
    let g:NeoComplCache_MinSyntaxLength = 3
    let g:NeoComplCache_EnableSkipCompletion = 1
    let g:NeoComplCache_SkipInputTime = '0.5'
    let g:NeoComplCache_SnippetsDir = $VIMFILES.'/snippets'
    " <TAB> completion.
    inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
    " snippets expand key
    imap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)
    smap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)


    "-----------------------------------------------------------------
    " plugin - matchit.vim 對%命令進行擴展使得能在嵌套標簽和語句之間跳轉
    " % 正向匹配 g% 反向匹配
    " [% 定位塊首 ]% 定位塊尾
    "-----------------------------------------------------------------


    "-----------------------------------------------------------------
    " plugin - vcscommand.vim 對%命令進行擴展使得能在嵌套標簽和語句之間跳轉
    " SVN/git管理工具
    "-----------------------------------------------------------------


    "-----------------------------------------------------------------
    " plugin – a.vim
    "-----------------------------------------------------------------
    配置vim在源碼中自動添加作者信息

    每個程序員都有自己心愛的代碼編輯和查看工具,相信不少Linux什么是Linux?下的程序員都喜歡用Vim,盡管Vim沒有SourceInsight這種依托于桌面環境的編輯器看起來那樣強大,但是Vim的高效、簡潔以及強大的可配置性都讓它吸引了無數忠實的fans。

      很多編輯器都支持在源代碼中自動添加作者信息的功能,SourceInsight就有這項功能。Vim默認是沒有這個功能,但是只要我們稍作配置,就可以實現這個功能了。

      在Linux下我們需要修改Vim的配置文件vimrc,位于:

      /etc/vim/vimrc

      在window下Vim的配置文件位于安裝目錄下的_vimrc。

      然后在配置文件中添加如下信息,就可以實現在源代碼中自動添加作者信息了:

      “將鍵盤上的F4功能鍵映射為添加作者信息的快捷鍵

      map ms:call TItleDet()'s

      functiON AddTitle()

      call append(0,"/*******************************************************************************")

      "call append(1,"#")

      call append(1," * Author : YangShuo")

      "call append(3,"#")

      call append(2," * Email : ys@farsight.com.cn")

      "call append(5,"#")

      call append(3," * LaST modified : ".strftime("%Y-%m-%d %H:%M"))

      "call append(7,"#")

      call append(4," * Filename : ".expand("%:t"))

      "call append(9,"#")

      call append(5," * Description : ")

      "call append(11,"#")

      call append(6," * *****************************************************************************/")

      echohl WarningMsg | echo "Successful in adding the copyright." | echohl None

      endf

      “更新最近修改時間和文件名

      normal m'

      execute '/# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@'

      normal "

      normal mk

      execute '/# *Filename:/s@:.*$@\=":\t\t".expand("%:t")@'

      execute "noh"

      normal 'k

      echohl WarningMsg | echo "Successful in updating the copy right."| echohl None

      endfunction

      “判斷前10行代碼里面,是否有Last modified這個單詞,

      “如果沒有的話,代表沒有添加過作者信息,需要新添加;

      “如果有的話,那么只需要更新即可

      function TitleDet()

      let n=1

      while n < 10

      let line = getline(n)

      if line =~'^\#\s*\S*Last\smodified:\S*.*$'

      call UpdateTitle()

      return

      endif

      let n = n + 1

      endwhile

      call AddTitle()

      endfunction

      這段配置在Linux和window下均可正常運行。這樣在一個C/C++/JAVA/C#的源代碼里面,只需要按一下F4,就可以自動添加作者信息了。大家只需要修改上面這段配置關于作者信息的代碼,就可以添加自己的信息了。

      這是在我電腦上運行的結果,看一看,是不是很帥:



      趕快動手吧,把這段配置添加到你的vimrc里,這樣你就可以輕松地在源文件開始添加你的相關信息了,讓我們的代碼更加規范。


    史上最強的 Vim 配置文件?-純文本版


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " _
    " __ | \
    " / | /
    " \__ | \
    " by Amix - http://amix.dk/
    "
    " Maintainer: Amir Salihefendic <amix3k at gmail.com>
    " Version: 2.7
    " Last Change: 12/10/06 00:09:21
    "
    " Sections:
    " ----------------------
    " *> General
    " *> Colors and Fonts
    " *> Fileformats
    " *> VIM userinterface
    " ------ *> Statusline
    " *> Visual
    " *> Moving around and tabs
    " *> General Autocommands
    " *> Parenthesis/bracket expanding
    " *> General Abbrevs
    " *> Editing mappings etc.
    " *> Command-line config
    " *> Buffer realted
    " *> Files and backups
    " *> Folding
    " *> Text options
    " ------ *> Indent
    " *> Spell checking
    " *> Plugin configuration
    " ------ *> Yank ring
    " ------ *> File explorer
    " ------ *> Minibuffer
    " ------ *> Tag list (ctags) - not used
    " ------ *> LaTeX Suite things
    " *> Filetype generic
    " ------ *> Todo
    " ------ *> VIM
    " ------ *> HTML related
    " ------ *> Ruby & PHP section
    " ------ *> Python section
    " ------ *> Cheetah section
    " ------ *> Vim section
    " ------ *> Java section
    " ------ *> JavaScript section
    " ------ *> C mappings
    " ------ *> SML
    " ------ *> Scheme bindings
    " *> Snippets
    " ------ *> Python
    " ------ *> javaScript
    " *> Cope
    " *> MISC
    "
    " Tip:
    " If you find anything that you can't understand than do this:
    " help keyword OR helpgrep keywords
    " Example:
    " Go into command-line mode and type helpgrep nocompatible, ie.
    " :helpgrep nocompatible
    " then press <leader>c to see the results, or :botright cw
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => General
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Get out of VI's compatible mode..
    set nocompatible
    "Sets how many lines of history VIM har to remember
    set history=400
    "Enable filetype plugin
    filetype plugin on
    filetype indent on
    "Set to auto read when a file is changed from the outside
    set autoread
    "Have the mouse enabled all the time:
    set mouse=a
    "Set mapleader
    let mapleader = ","
    let g:mapleader = ","
    "Fast saving
    nmap <leader>w :w!<cr>
    nmap <leader>f :find<cr>
    "Fast reloading of the .vimrc
    map <leader>s :source ~/vim_local/vimrc<cr>
    "Fast editing of .vimrc
    map <leader>e :e! ~/vim_local/vimrc<cr>
    "When .vimrc is edited, reload it
    autocmd! bufwritepost vimrc source ~/vim_local/vimrc
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Colors and Fonts
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Enable syntax hl
    syntax enable
    "Set font to Monaco 10pt
    if MySys() == "mac"
    set gfn=Bitstream\ Vera\ Sans\ Mono:h14
    set nomacatsui
    set termencoding=macroman
    elseif MySys() == "linux"
    set gfn=Monospace\ 11
    endif
    if has("gui_running")
    set guioptions-=T
    let psc_style='cool'
    colorscheme ps_color
    else
    set background=dark
    colorscheme zellner
    endif
    "Some nice mapping to switch syntax (useful if one mixes different languages in one file)
    map <leader>1 :set syntax=cheetah<cr>
    map <leader>2 :set syntax=xhtml<cr>
    map <leader>3 :set syntax=python<cr>
    map <leader>4 :set ft=javascript<cr>
    map <leader>$ :syntax sync fromstart<cr>
    autocmd BufEnter * :syntax sync fromstart
    "Highlight current
    if has("gui_running")
    set cursorline
    hi cursorline guibg=#333333
    hi CursorColumn guibg=#333333
    endif
    "Omni menu colors
    hi Pmenu guibg=#333333
    hi PmenuSel guibg=#555555 guifg=#ffffff
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Fileformats
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Favorite filetypes
    set ffs=unix,dos,mac
    nmap <leader>fd :se ff=dos<cr>
    nmap <leader>fu :se ff=unix<cr>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => VIM userinterface
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Set 7 lines to the curors - when moving vertical..
    set so=7
    "Turn on WiLd menu
    set wildmenu
    "Always show current position
    set ruler
    "The commandbar is 2 high
    set cmdheight=2
    "Show line number
    set nu
    "Do not redraw, when running macros.. lazyredraw
    set lz
    "Change buffer - without saving
    set hid
    "Set backspace
    set backspace=eol,start,indent
    "Bbackspace and cursor keys wrap to
    set whichwrap+=<,>,h,l
    "Ignore case when searching
    set ignorecase
    set incsearch
    "Set magic on
    set magic
    "No sound on errors.
    set noerrorbells
    set novisualbell
    set t_vb=
    "show matching bracets
    set showmatch
    "How many tenths of a second to blink
    set mat=2
    "Highlight search things
    set hlsearch
    """"""""""""""""""""""""""""""
    " => Statusline
    """"""""""""""""""""""""""""""
    "Always hide the statusline
    set laststatus=2
    function! CurDir()
    let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
    return curdir
    endfunction
    "Format the statusline
    set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
    """"""""""""""""""""""""""""""
    " => Visual
    """"""""""""""""""""""""""""""
    " From an idea by Michael Naumann
    function! VisualSearch(direction) range
    let l:saved_reg = @"
    execute "normal! vgvy"
    let l:pattern = escape(@", '\\/.*$^~[]')
    let l:pattern = substitute(l:pattern, "\n$", "", "")
    if a:direction == 'b'
    execute "normal ?" . l:pattern . "^M"
    else
    execute "normal /" . l:pattern . "^M"
    endif
    let @/ = l:pattern
    let @" = l:saved_reg
    endfunction
    "Basically you press * or # to search for the current selection !! Really useful
    vnoremap <silent> * :call VisualSearch('f')<CR>
    vnoremap <silent> # :call VisualSearch('b')<CR>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Moving around and tabs
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Map space to / and c-space to ?
    map <space> /
    map <c-space> ?
    "Smart way to move btw. windows
    map <C-j> <C-W>j
    map <C-k> <C-W>k
    map <C-h> <C-W>h
    map <C-l> <C-W>l
    "Actually, the tab does not switch buffers, but my arrows
    "Bclose function ca be found in "Buffer related" section
    map <leader>bd :Bclose<cr>
    map <down> <leader>bd
    "Use the arrows to something usefull
    map <right> :bn<cr>
    map <left> :bp<cr>
    "Tab configuration
    map <leader>tn :tabnew %<cr>
    map <leader>te :tabedit
    map <leader>tc :tabclose<cr>
    map <leader>tm :tabmove
    try
    set switchbuf=usetab
    set stal=2
    catch
    endtry
    "Moving fast to front, back and 2 sides ;)
    imap <m-$> <esc>$a
    imap <m-0> <esc>0i
    imap <D-$> <esc>$a
    imap <D-0> <esc>0i
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => General Autocommands
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Switch to current dir
    map <leader>cd :cd %:p:h<cr>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Parenthesis/bracket expanding
    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    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 $w <esc>`>a"<esc>`<i"<esc>
    "Map auto complete of (, ", ', [
    inoremap $1 ()<esc>:let leavechar=")"<cr>i
    inoremap $2 []<esc>:let leavechar="]"<cr>i
    inoremap $4 {<esc>o}<esc>:let leavechar="}"<cr>O
    inoremap $3 {}<esc>:let leavechar="}"<cr>i
    inoremap $q ''<esc>:let leavechar="'"<cr>i
    inoremap $w ""<esc>:let leavechar='"'<cr>i
    au BufNewFile,BufRead *.\(vim\)\@! inoremap " ""<esc>:let leavechar='"'<cr>i
    au BufNewFile,BufRead *.\(txt\)\@! inoremap ' ''<esc>:let leavechar="'"<cr>i
    imap <m-l> <esc>:exec "normal f" . leavechar<cr>a
    imap <d-l> <esc>:exec "normal f" . leavechar<cr>a
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => General Abbrevs
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "My information
    iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
    iab xname Amir Salihefendic
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Editing mappings etc.
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Remap VIM 0
    map 0 ^
    "Move a line of text using control
    nmap <M-j> mz:m+<cr>`z
    nmap <M-k> mz:m-2<cr>`z
    vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
    vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
    if MySys() == "mac"
    nmap <D-j> <M-j>
    nmap <D-k> <M-k>
    vmap <D-j> <M-j>
    vmap <D-k> <M-k>
    endif
    func! DeleteTrailingWS()
    exe "normal mz"
    %s/\s\+$//ge
    exe "normal `z"
    endfunc
    autocmd BufWrite *.py :call DeleteTrailingWS()
    set completeopt=menu
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Command-line config
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    func! Cwd()
    let cwd = getcwd()
    return "e " . cwd
    endfunc
    func! DeleteTillSlash()
    let g:cmd = getcmdline()
    if MySys() == "linux" || MySys() == "mac"
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
    else
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
    endif
    if g:cmd == g:cmd_edited
    if MySys() == "linux" || MySys() == "mac"
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
    else
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
    endif
    endif
    return g:cmd_edited
    endfunc
    func! CurrentFileDir(cmd)
    return a:cmd . " " . expand("%:p:h") . "/"
    endfunc
    "Smart mappings on the command line
    cno $h e ~/
    cno $d e ~/Desktop/
    cno $j e ./
    cno $q <C-\>eDeleteTillSlash()<cr>
    cno $c e <C-\>eCurrentFileDir("e")<cr>
    cno $tc <C-\>eCurrentFileDir("tabnew")<cr>
    cno $th tabnew ~/
    cno $td tabnew ~/Desktop/
    "Bash like
    cnoremap <C-A> <Home>
    cnoremap <C-E> <End>
    cnoremap <C-K> <C-U>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Buffer realted
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Fast open a buffer by search for a name
    map <c-q> :sb
    "Open a dummy buffer for paste
    map <leader>q :e ~/buffer<cr>
    "Restore cursor to file position in previous editing session
    set viminfo='10,\"100,:20,%,n~/.viminfo
    au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
    " Buffer - reverse everything ... :)
    map <F9> ggVGg?
    " Don't close window, when deleting a buffer
    command! Bclose call <SID>BufcloseCloseIt()
    function! <SID>BufcloseCloseIt()
    let l:currentBufNum = bufnr("%")
    let l:alternateBufNum = bufnr("#")
    if buflisted(l:alternateBufNum)
    buffer #
    else
    bnext
    endif
    if bufnr("%") == l:currentBufNum
    new
    endif
    if buflisted(l:currentBufNum)
    execute("bdelete! ".l:currentBufNum)
    endif
    endfunction
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Files and backups
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Turn backup off
    set nobackup
    set nowb
    set noswapfile
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Folding
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Enable folding, I find it very useful
    set nofen
    set fdl=0
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Text options
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    set expandtab
    set shiftwidth=2
    map <leader>t2 :set shiftwidth=2<cr>
    map <leader>t4 :set shiftwidth=4<cr>
    au FileType html,python,vim,javascript setl shiftwidth=2
    au FileType html,python,vim,javascript setl tabstop=2
    au FileType java setl shiftwidth=4
    au FileType java setl tabstop=4
    set smarttab
    set lbr
    set tw=500
    """"""""""""""""""""""""""""""
    " => Indent
    """"""""""""""""""""""""""""""
    "Auto indent
    set ai
    "Smart indet
    set si
    "C-style indeting
    set cindent
    "Wrap lines
    set wrap
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Spell checking
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    map <leader>sn ]s
    map <leader>sp [s
    map <leader>sa zg
    map <leader>s? z=
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Plugin configuration
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    """"""""""""""""""""""""""""""
    " => Vim Grep
    """"""""""""""""""""""""""""""
    let Grep_Skip_Dirs = 'RCS CVS SCCS .svn'
    let Grep_Cygwin_Find = 1
    """"""""""""""""""""""""""""""
    " => Yank Ring
    """"""""""""""""""""""""""""""
    map <leader>y :YRShow<cr>
    """"""""""""""""""""""""""""""
    " => File explorer
    """"""""""""""""""""""""""""""
    "Split vertically
    let g:explVertical=1
    "Window size
    let g:explWinSize=35
    let g:explSplitLeft=1
    let g:explSplitBelow=1
    "Hide some files
    let g:explHideFiles='^\.,.*\.class$,.*\.swp$,.*\.pyc$,.*\.swo$,\.DS_Store$'
    "Hide the help thing..
    let g:explDetailedHelp=0
    """"""""""""""""""""""""""""""
    " => Minibuffer
    """"""""""""""""""""""""""""""
    let g:miniBufExplModSelTarget = 1
    let g:miniBufExplorerMoreThanOne = 2
    let g:miniBufExplModSelTarget = 0
    let g:miniBufExplUseSingleClick = 1
    let g:miniBufExplMapWindowNavVim = 1
    let g:miniBufExplVSplit = 25
    let g:miniBufExplSplitBelow=1
    let g:bufExplorerSortBy = "name"
    autocmd BufRead,BufNew :call UMiniBufExplorer
    """"""""""""""""""""""""""""""
    " => Tag list (ctags) - not used
    """"""""""""""""""""""""""""""
    "let Tlist_Ctags_Cmd = "/sw/bin/ctags-exuberant"
    "let Tlist_Sort_Type = "name"
    "let Tlist_Show_Menu = 1
    "map <leader>t :Tlist<cr>
    """"""""""""""""""""""""""""""
    " => LaTeX Suite things
    """"""""""""""""""""""""""""""
    set grepprg=grep\ -nH\ $*
    let g:Tex_DefaultTargetFormat="pdf"
    let g:Tex_ViewRule_pdf='xpdf'
    "Bindings
    autocmd FileType tex map <silent><leader><space> :w!<cr> :silent! call Tex_RunLaTeX()<cr>
    "Auto complete some things ;)
    autocmd FileType tex inoremap $i \indent
    autocmd FileType tex inoremap $* \cdot
    autocmd FileType tex inoremap $i \item
    autocmd FileType tex inoremap $m \[<cr>\]<esc>O
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Filetype generic
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Todo
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    au BufNewFile,BufRead *.todo so ~/vim_local/syntax/amido.vim
    """"""""""""""""""""""""""""""
    " => VIM
    """"""""""""""""""""""""""""""
    autocmd FileType vim map <buffer> <leader><space> :w!<cr>:source %<cr>
    """"""""""""""""""""""""""""""
    " => HTML related
    """"""""""""""""""""""""""""""
    " HTML entities - used by xml edit plugin
    let xml_use_xhtml = 1
    "let xml_no_auto_nesting = 1
    "To HTML
    let html_use_css = 1
    let html_number_lines = 0
    let use_xhtml = 1
    """"""""""""""""""""""""""""""
    " => Ruby & PHP section
    """"""""""""""""""""""""""""""
    autocmd FileType ruby map <buffer> <leader><space> :w!<cr>:!ruby %<cr>
    autocmd FileType php compiler php
    autocmd FileType php map <buffer> <leader><space> <leader>cd:w<cr>:make %<cr>
    """"""""""""""""""""""""""""""
    " => Python section
    """"""""""""""""""""""""""""""
    "Run the current buffer in python - ie. on leader+space
    au FileType python so ~/vim_local/syntax/python.vim
    autocmd FileType python map <buffer> <leader><space> :w!<cr>:!python %<cr>
    autocmd FileType python so ~/vim_local/plugin/python_fold.vim
    "Set some bindings up for 'compile' of python
    autocmd FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
    autocmd FileType python set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
    "Python iMaps
    au FileType python set cindent
    au FileType python inoremap <buffer> $r return
    au FileType python inoremap <buffer> $s self
    au FileType python inoremap <buffer> $c ##<cr>#<space><cr>#<esc>kla
    au FileType python inoremap <buffer> $i import
    au FileType python inoremap <buffer> $p print
    au FileType python inoremap <buffer> $d """<cr>"""<esc>O
    "Run in the Python interpreter
    function! Python_Eval_VSplit() range
    let src = tempname()
    let dst = tempname()
    execute ": " . a:firstline . "," . a:lastline . "w " . src
    execute ":!python " . src . " > " . dst
    execute ":pedit! " . dst
    endfunction
    au FileType python vmap <F7> :call Python_Eval_VSplit()<cr>
    """"""""""""""""""""""""""""""
    " => Cheetah section
    """""""""""""""""""""""""""""""
    autocmd FileType cheetah set ft=xml
    autocmd FileType cheetah set syntax=cheetah
    """""""""""""""""""""""""""""""
    " => Vim section
    """""""""""""""""""""""""""""""
    autocmd FileType vim set nofen
    """""""""""""""""""""""""""""""
    " => Java section
    """""""""""""""""""""""""""""""
    au FileType java inoremap <buffer> <C-t> System.out.println();<esc>hi
    "Java comments
    autocmd FileType java source ~/vim_local/macros/jcommenter.vim
    autocmd FileType java let b:jcommenter_class_author='Amir Salihefendic (amix@amix.dk)'
    autocmd FileType java let b:jcommenter_file_author='Amir Salihefendic (amix@amix.dk)'
    autocmd FileType java map <buffer> <F2> :call JCommentWriter()<cr>
    "Abbr'z
    autocmd FileType java inoremap <buffer> $pr private
    autocmd FileType java inoremap <buffer> $r return
    autocmd FileType java inoremap <buffer> $pu public
    autocmd FileType java inoremap <buffer> $i import
    autocmd FileType java inoremap <buffer> $b boolean
    autocmd FileType java inoremap <buffer> $v void
    autocmd FileType java inoremap <buffer> $s String
    "Folding
    function! JavaFold()
    setl foldmethod=syntax
    setl foldlevelstart=1
    syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
    syn match foldImports /\(\n\?import.\+;\n\)\+/ transparent fold
    function! FoldText()
    return substitute(getline(v:foldstart), '{.*', '{...}', '')
    endfunction
    setl foldtext=FoldText()
    endfunction
    au FileType java call JavaFold()
    au FileType java setl fen
    au BufEnter *.sablecc,*.scc set ft=sablecc
    """"""""""""""""""""""""""""""
    " => JavaScript section
    """""""""""""""""""""""""""""""
    au FileType javascript so ~/vim_local/syntax/javascript.vim
    function! JavaScriptFold()
    setl foldmethod=syntax
    setl foldlevelstart=1
    syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
    function! FoldText()
    return substitute(getline(v:foldstart), '{.*', '{...}', '')
    endfunction
    setl foldtext=FoldText()
    endfunction
    au FileType javascript call JavaScriptFold()
    au FileType javascript setl fen
    au FileType javascript imap <c-t> console.log();<esc>hi
    au FileType javascript imap <c-a> alert();<esc>hi
    au FileType javascript setl nocindent
    au FileType javascript inoremap <buffer> $r return
    au FileType javascript inoremap <buffer> $d //<cr>//<cr>//<esc>ka<space>
    au FileType javascript inoremap <buffer> $c /**<cr><space><cr>**/<esc>ka
    """"""""""""""""""""""""""""""
    " => HTML
    """""""""""""""""""""""""""""""
    au FileType html,cheetah set ft=xml
    au FileType html,cheetah set syntax=html
    """"""""""""""""""""""""""""""
    " => C mappings
    """""""""""""""""""""""""""""""
    autocmd FileType c map <buffer> <leader><space> :w<cr>:!gcc %<cr>
    """""""""""""""""""""""""""""""
    " => SML
    """""""""""""""""""""""""""""""
    autocmd FileType sml map <silent> <buffer> <leader><space> <leader>cd:w<cr>:!sml %<cr>
    """"""""""""""""""""""""""""""
    " => Scheme bidings
    """"""""""""""""""""""""""""""
    autocmd BufNewFile,BufRead *.scm map <buffer> <leader><space> <leader>cd:w<cr>:!petite %<cr>
    autocmd BufNewFile,BufRead *.scm inoremap <buffer> <C-t> (pretty-print )<esc>i
    autocmd BufNewFile,BufRead *.scm vnoremap <C-t> <esc>`>a)<esc>`<i(pretty-print <esc>
    """"""""""""""""""""""""""""""
    " => SVN section
    """""""""""""""""""""""""""""""
    map <F8> :new<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>gg
    """"""""""""""""""""""""""""""
    " => Snippets
    """""""""""""""""""""""""""""""
    "You can use <c-j> to goto the next <++> - it is pretty smart ;)
    """""""""""""""""""""""""""""""
    " => Python
    """""""""""""""""""""""""""""""
    autocmd FileType python inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("def <++>(<++>):\n<++>\nreturn <++>")<cr>
    autocmd FileType python inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("class <++>:\n<++>")<cr>
    autocmd FileType python inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for <++> in <++>:\n<++>")<cr>
    autocmd FileType python inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if <++>:\n<++>")<cr>
    autocmd FileType python inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if <++>:\n<++>\nelse:\n<++>")<cr>
    """""""""""""""""""""""""""""""
    " => JavaScript
    """""""""""""""""""""""""""""""
    autocmd FileType cheetah,html,javascript inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("function <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr>
    autocmd filetype cheetah,html,javascript inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {\n<++>;\n}")<cr>
    autocmd FileType cheetah,html,javascript inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}")<cr>
    autocmd FileType cheetah,html,javascript inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}\nelse {\n<++>;\n}")<cr>
    """""""""""""""""""""""""""""""
    " => HTML
    """""""""""""""""""""""""""""""
    autocmd FileType cheetah,html inorea <buffer> cahref <c-r>=IMAP_PutTextWithMovement('<a href="<++>"><++></a>')<cr>
    autocmd FileType cheetah,html inorea <buffer> cbold <c-r>=IMAP_PutTextWithMovement('<b><++></b>')<cr>
    autocmd FileType cheetah,html inorea <buffer> cimg <c-r>=IMAP_PutTextWithMovement('<img src="<++>" alt="<++>" />')<cr>
    autocmd FileType cheetah,html inorea <buffer> cpara <c-r>=IMAP_PutTextWithMovement('<p><++></p>')<cr>
    autocmd FileType cheetah,html inorea <buffer> ctag <c-r>=IMAP_PutTextWithMovement('<<++>><++></<++>>')<cr>
    autocmd FileType cheetah,html inorea <buffer> ctag1 <c-r>=IMAP_PutTextWithMovement("<<++>><cr><++><cr></<++>>")<cr>
    """""""""""""""""""""""""""""""
    " => Java
    """""""""""""""""""""""""""""""
    autocmd FileType java inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("public<++> <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr>
    autocmd FileType java inorea <buffer> cfunpr <c-r>=IMAP_PutTextWithMovement("private<++> <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr>
    autocmd FileType java inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {\n<++>;\n}")<cr>
    autocmd FileType java inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}")<cr>
    autocmd FileType java inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}\nelse {\n<++>;\n}")<cr>
    autocmd FileType java inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("class <++> <++> {\n<++>\n}")<cr>
    autocmd FileType java inorea <buffer> cmain <c-r>=IMAP_PutTextWithMovement("public static void main(String[] argv) {\n<++>\n}")<cr>
    "Presse c-q insted of space (or other key) to complete the snippet
    imap <C-q> <C-]>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Cope
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "For Cope
    map <silent> <leader><cr> :noh<cr>
    "Orginal for all
    map <leader>n :cn<cr>
    map <leader>p :cp<cr>
    map <leader>c :botright cw 10<cr>
    map <c-u> <c-l><c-j>:q<cr>:botright cw 10<cr>
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => MISC
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Remove the Windows ^M
    noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
    "Paste toggle - when pasting something in, don't indent.
    set pastetoggle=<F3>
    "Remove indenting on empty lines
    map <F2> :%s/\s*$//g<cr>:noh<cr>''
    "Super paste
    inoremap <C-v> <esc>:set paste<cr>mui<C-R>+<esc>mv'uV'v=:set nopaste<cr>
    "A function that inserts links & anchors on a TOhtml export.
    " Notice:
    " Syntax used is:
    " *> Link
    " => Anchor
    function! SmartTOHtml()
    TOhtml
    try
    %s/&quot;\s\+\*&gt; \(.\+\)</" <a href="#\1" style="color: cyan">\1<\/a></g
    %s/&quot;\(-\|\s\)\+\*&gt; \(.\+\)</" \&nbsp;\&nbsp; <a href="#\2" style="color: cyan;">\2<\/a></g
    %s/&quot;\s\+=&gt; \(.\+\)</" <a name="\1" style="color: #fff">\1<\/a></g
    catch
    endtry
    exe ":write!"
    exe ":bd"
    endfunction

    # 最佳vim技巧
    ----------------------------------------
    # 信息來源
    ----------------------------------------
    www.vim.org         : 官方站點
    comp.editors        : 新聞組
    http://www.newriders.com/books/opl/ebooks/0735710015.html : Vim書籍
    http://vimdoc.sourceforge.net/cgi-bin/vim2html2.pl : 關于vim的可查詢文檔
    http://vimdoc.sourceforge.net/vimfaq.html          : VIM FAQ
    ----------------------------------------
    # 基礎
    ----------------------------------------
    * # g* g#           : 尋找光標處的狹義單詞(<cword>) (前向/后向)
    %                   : 括號配對尋找 {}[]()
    matchit.vim         : 使得 % 能夠配對標記 <tr><td><script> <?php 等等
    <C-N><C-P>          : 插入模式下的單詞自動完成
    <C-X><C-L>          : 行自動完成(超級有用)
    /<C-R><C-W>         : 把狹義單詞 <cword> 寫到 搜索命令 行
    /<C-R><C-A>         : 把廣義單詞 <cWORD> 寫到 搜索命令 行
    :set ignorecase     : 搜索時忽略大小寫
    :syntax on          : 在 Perl,HTML,PHP 等中進行語法著色
    :h regexp<C-D>      : 按下 control-D 鍵即可得到包含有 regexp 的幫助主題的列表
                        : (使用TAB可以實現幫助的自動補齊)
    ----------------------------------------
    # 使更新 _vimrc 更容易
    :nmap ,s :source $VIM/_vimrc
    # 譯釋:nmap 是綁定一個在normal模式下的快捷鍵
    :nmap ,v :e $VIM/_vimrc
    # 譯釋:在normal模式下,先后按下 ,s 兩個鍵執行_vimrc,而 ,v 則是編輯_vimrc

    ----------------------------------------
    # visual 模式 (例子是:輕松添加其他的 HTML Tags)
    :vmap sb "zdi<b><C-R>z</b><ESC>  : 在visual模式下選中的文字前后分別加上<b>和</b>
    # 譯釋:vmap 是綁定一個在visual模式下的快捷鍵

    # 譯釋:原理:在visual模式下,"zd 把一個選中的區域命名為z 然后刪除,
    # i 進入插入模式,輸入<b>,<C-R>z 撤銷剛才的刪除,然后再寫入</b>,
    # 最后<ESC>返回normal模式

    # 譯釋:"z 命令創建一個選中的區域為register,并把它命名為z

    # 譯釋:更令人開心的有:在visual模式下選中幾行,然后輸入 2> ,
    #       則選中的行會全部縮進兩個tab
    #       555,偶一開始還是用 :xx,xx s/^/\t\t/,好傻啊!

    :vmap st "zdi<?= <C-R>z ?><ESC>  : 在visual模式下選中的文字前后分別加上<?= 和 ?>
    ----------------------------------------
    # 文件瀏覽
    :Ex                             : 開啟目錄瀏覽器,注意首字母E是大寫的
    :Sex                            : 在一個分割的窗口中開啟目錄瀏覽器
    :ls                             : 顯示當前buffer的情況
    :cd ..                          : 進入父目錄
    :args                           : 顯示目前打開的文件
    :lcd %:p:h                      : 更改到當前文件所在的目錄
    # 譯釋:lcd是緊緊改變當前窗口的工作路徑,% 是代表當前文件的文件名,
    # 加上 :p擴展成全名(就是帶了路徑),加上 :h析取出路徑

    :autocmd BufEnter * lcd %:p:h   : 自動更改到當前文件所在的目錄
    # 譯釋:autocmd指定一個自動命令,BufEnter指定一個事件,* 指定事件的對象,
    # lcd %:p:h 指定一個動作
    # hehe,好像和寫記敘文差不多
    ----------------------------------------
    # 緩沖區(buffer)瀏覽器 (第三方的一個最流行的腳本)
    # 需要下載 bufexplorer.vim ,http://www.vim.org/script.php?script_id=42 上就有
    \be                             : 在緩沖區瀏覽器中打開緩沖區列表
    \bs                             : 以分割窗口的形式打開緩沖區瀏覽器
    ----------------------------------------
    # 大小寫轉換
    guu                             : 行小寫
    gUU                             : 行大寫
    g~~                             : 行翻轉(當然指大小寫啦)
    # 譯釋: g 是大小寫轉換命令(greate),u/U/~是三種轉換形式(小寫/大寫/翻轉),
    # 最后一個重復則表示該轉換是對于一行而言的


    guw                             : 字大寫(狹義字) 譯注:建議對比iw
    gUw                             : 字小寫(狹義字)
    g~w                             : 字翻轉(狹義字)
    # 譯釋:最后一個w 表示該轉換是對于一個字而言的,由于是在normal模式下,
    # 所以這個w 表示一個狹義字<cword> 

    vEU                             : 字大寫(廣義字)
    vE~                             : 字翻轉(廣義字)
    # 譯釋:vE 這個指令組合會進入visual模式,然后選擇一個廣義字<CWORD>

    ggguG                           : 把整個文章全部小寫(ft!bt!)
    gf                              : 取當前光標處的廣義字作為文件名,然后試圖打開它!
    # 譯釋:為什么是廣義字呢?因為這樣可以方便的取到路徑啊,像/var/www/html/index.htm

    ga                              : 顯示光標處字符的ascii,hex,oct,...暈菜的一堆轉換
    ggVGg?                          : 用rot13編碼整個文件(暈!)
    # 譯釋:gg到文件首行首字符,V進入Visual-Line模式,G到文件末行首字符,
    #       這樣就選中了整篇文章,然后g?就是用rot13編碼整個文件啦

    # 【關于rot13——誰讓英文是偶數個字母啊】
    # ROT13 是一種簡單的編碼,它把字母分成前后兩組,每組13個,編碼和解碼
    # 的算法相同,僅僅交換字母的這兩個部分,即:[a..m] --> [n..z] 和 [n..z]
    # --> [a..m] 。 ROT13 用簡易的手段使得信件不能直接被識別和閱
    # 讀,也不會被搜索匹配程序用通常的方法直接找到。經常用于 USENET 中發表一
    # 些攻擊性或令人不快的言論或有簡單保密需要的文章。
    # 由于 ROT13 是自逆算法,所以,解碼和編碼是同一個過程。

    <C-A>,<C-X>                     : 增加,減少 光標處的狹義字所表示的數字
                                    :(,僅僅是分割了這兩個命令,不是命令的一部分)
                                    : Win32的用戶可能需要重新定義一下Ctrl-A,呵呵
    # 譯注:good guy, 令人不得不想到perl的數字串

    <C-R>=5*5                       : 插入25 (這是一個迷你計算器耶!)
    ----------------------------------------
    # 好玩的東東
    :h 42            : 也可以訪問 http://www.google.com/search?q=42
                     : 第一個結果就是 News. Douglas Adams 1952 - 2001. 
                     : Floor 42 extends its deepest sympathies to
                     : the family, friends, and fans of Douglas Adams.
    :h holy-grail
    :h!
    ----------------------------------------
    # 標記和移動
    '.               : 跳到最后修改的那一行 (超級有用)(ft,怎么又是這個評價)
    `.               : 不僅跳到最后修改的那一行,還要定位到修改點
    <C-O>            : 依次沿著你的跳轉記錄向回跳 (從最近的一次開始)
    <C-I>            : 依次沿著你的跳轉記錄向前跳
    :ju(mps)         : 列出你跳轉的足跡
    :help jump-motions
    :history         : 列出歷史命令記錄
    :his c           : 命令行命令歷史
    :his s           : 搜索命令歷史
    q/               : 搜索命令歷史的窗口
    q:               : 命令行命令歷史的窗口
    :<C-F>           : 歷史命令記錄的窗口
    ----------------------------------------
    # 縮寫和鍵盤映射(原文中文件舉例都用了c:/aaa/x,偶全給他改成/path/file了,哼唧)
    :map   <f7>   :'a,'bw! /path/file
    # 譯釋:map是映射一個normal模式下的鍵
    # 這里是把F7鍵映射成把標記a到標記b中間的內容另存為一個文件/path/file
    # 標記(mark)的方法:把光標移動到需要標記的地方,輸入m,然后輸入標記名,例如a
    # 引用標記的方法:'a ,即:單引號加標記名

    :map   <f8>   :r /path/file
    # 譯釋:把F8鍵映射成在當前位置插入文件/path/file的內容
    :map   <f11>  :.w! /path/file2<CR>
    # 譯釋:.(點號)表示當前行
    # 所以F11就是把當前行存為/path/file2
    # 最后的<CR>表示一個回車
    :map   <f12>  :r /path/file2<CR>
    :ab php          : 列出php表示的縮寫
    # 譯釋:定義一個縮寫使用::iab hm hmisty
    # 一個有趣的現象是,它列出的會是php和它的前子串開頭的縮寫
    # 例如,有這么幾個縮寫:
    # h => hmisty1 , hm => hmisty2 , hmi => hmisty3, m => hmisty4
    # 那么使用 :ab hm會顯示這么幾個縮寫:hm 和 h
    # 而不是你想象中的 hm 和 hmi

    :map ,           : 列出以逗號開始的鍵盤映射
    # 譯釋:一般而言,我們稱這些逗號開始的組合鍵為“逗號命令”
    # 不過hmisty更喜歡用;構成“分號命令”
    # 而且不是用map,而是用imap
    # 因為偶懶么,懶得按<Esc>,所以直接在insert模式下就執行命令了
    # 為什么用分號呢?因為我最常用它寫程序啊
    # perl/C/C++/object pascal/java,都是用分號結束一個語句
    # 我們一般很少在分號后面連續寫其他字符
    # 所以用“分號+其他鍵”就很少會在輸入的時候造成沖突

    # 在鍵盤映射中常用的表示
    <CR>             : 回車
    <ESC>            : Esc
    <LEADER>         : 轉義符號 \
    <BAR>            : 管道符號 |
    ----------------------------------------
    # 列出寄存器(Registers)
    :reg             : 顯示所有當前的registers
    "1p              : "表示引用register,1表示一個名字叫做1的register,
                     : p就是粘貼(paste)命令
    # 譯釋:"也用來定義register
    # 先輸入 ",表示定義register
    # 然后輸入名字,如0~9,a~z
    # 然后執行刪除或復制命令,如dd或y,
    #         或者是visual模式下的d(刪除選中的部分)或y(復制選中的部分)
    # 則被刪除或復制的部分就被存入了這個命名的register
    #
    # 觀察:一個特殊的register, "" ,里面存儲了一個匿名的刪除/復制
    # 在你執行dd或y的時候,被作用的部分被存到了""中
    # 這些和perl是多么像啊
    ----------------------------------------
    # Useful trick
    "ayy@a           : 把當前行作為一個Vim命令來執行
    # 譯釋:"ayy 是定義當前行到register a,然后@a是執行register a中存儲的指令
    # yy: 復制一行
    # 10yy: 復制從此向下的10行

    yy@"             : 用上面所提到的那個匿名register
    ----------------------------------------
    # 從其他程序獲取輸出 (需要外部程序)
    :r!ls.exe        : 讀取ls的輸出到當前位置
    !!date           : 讀取date的輸出 (但是會替換當前行的內容)
    # 譯釋:其實你輸入了!!后,vim就自動轉換到 :.! 等待你繼續輸入

    # 使用外部程序sort進行排序(sort是Unix標準命令,ls,date也是)
    :%!sort -u       : 使用sort程序排序整個文件(用結果重寫文件)
    # 譯釋:%表示整個文件的所有行
    # !sort表示執行外部命令sort
    # -u是sort的參數,man sort看看,這個參數的意義是合并相同的行
    # u就是unique,如果兩行內容相同,則結果中只保留一行的說

    :'a,'b!sort -u   : 對mark a 到mark b中間的內容進行排序
    !1} sort -u      : 排序當前段落 (只能在normal模式下使用!!)
    # 譯釋:!表示使用filter,1}表示filter的對象是從當前行開始向后數一段
    # 段落指到空行處結束,不包括空行
    # 其實你一旦輸入 !1},vim就自動計算當前段落應該到那一行(eg.+5),然后生成
    # :.,.+5! 等待之后輸入sort -u,回車,完成操作
    # .表示當前行,.+5當然就是當前行向后數5行
    ----------------------------------------
    # 多文檔操作 (基礎)
    # 譯注:用 :ls! 可以顯示出當前所有的buffer
    :bn              : 跳轉到下一個buffer

    :bp              : 跳轉到上一個buffer
    :wn              : 存盤當前文件并跳轉到下一個(又是“超級……”,ft!)
    :wp              : 存盤當前文件并跳轉到上一個
    :bd              : 把這個文件從buffer列表中做掉
    :bun             : 卸掉buffer (關閉這個buffer的窗口但是不把它從列表中做掉)
    :badd file.c     : 把文件file.c添加到buffer列表
    :b 3             : 跳到第3個buffer
    :b main          : 跳到一個名字中包含main的buffer,例如main.c 
                     : (ultra,這個怎么翻譯?:()
    :sav php.html    : 把當前文件存為php.html并打開php.html
    :sav! %<.bak     : 換一個后綴保存
    :e!              : 返回到修改之前的文件(修改之后沒有存盤)
    :w /path/%       : 把文件存到一個地兒
    :e #             : 編輯標記為#的buffer(這個buffer必須含有一個可編輯的文件)
                     : 用ls命令就能看到哪一個buffer有#
                     : %a表示當前正在編輯的buffer
                     : u 表示不能編輯或者已經被做掉的buffer

    :e #3            : 編輯編號為3的buffer(這個buffer必須含有一個可編輯的文件)
    :rew             : 回到第一個可編輯的文件
    :brew            : 回到第一個buffer
    :sp fred.txt     : 在一個水平分割的窗口中打開文件fred.txt
    # 譯注:vs fred.txt可以實現垂直分割
    :sball           : 把當前所有含有可編輯文件的buffer顯示到一個分割窗口中
                     : (偶該考慮把super翻譯成 高級指令 了,ft)

    :map   <F5> :ls<CR>:e # : 在normal模式下按F5鍵,則會顯示所有含有一個
                     : 可編輯文件的buffer,然后提示你輸入buffer的序號,
                     : 輸入后回車,則編輯這個buffer
    # 譯注:這是一個鍵盤綁定

    :set hidden      : 允許不保存buffer而切換buffer (w/o=without)
    ----------------------------------------
    # 在分割窗口中快速切換
    :map <C-J> <C-W>j<C-W>_
    # 譯注:原文此處有誤,前面應該加上冒號
    # 這是一個鍵盤綁定,把Ctrl-J定義成切換到下一個窗口并最大化
    :map <C-K> <C-W>k<C-W>_
    ----------------------------------------
    # 命令錄制 (最佳技巧,ft)
    qq  #錄制到q
    ... #輸入一系列復雜的指令
    q   #再次按q停止錄制
    @q  #執行q中存儲的指令
    @@  #重復執行
    # 編輯register/錄制
    "ap #把register a中的內容貼到當前位置
    ... #現在你可以修改它了
    "add#刪除之,重新存入register a 
    @a  #執行register a中的指令
    ----------------------------------------
    # _vimrc基礎
    :set incsearch                        : 實時匹配你輸入的內容
    :set wildignore=*.o,*.obj,*.bak,*.exe : tab鍵的自動完成現在會忽略這些
    :set shiftwidth=4                     : 現在自動縮進將是4個字符
    # 譯注:一個tab位通常是8個字符
    # 所以,我們還要設定 :set tabstop=4,這樣,所有的縮進都是4字符了
    # emacs默認就是4字符縮進吧?
    :set vb t_vb=".                        : 沉默方式(不要叫beep!)
    ----------------------------------------
    # 加載windows iexplorer來瀏覽(我想這只有在windows下用gvim才能用到)
    :nmap ,f :update<CR>:silent !start c:\progra~1\intern~1\iexplore.exe file://%:p
    # 譯釋:nmap是做一個normal模式下的鍵盤綁定
    # 這里綁定了一個逗號命令 ,f
    # :update是寫這個文件,與:w不同,它只有當文件被修改了的時候才寫
    # :silent別讓彈出窗口報告執行結果
    # !...后面就是執行windows命令了。呵呵,去問bill gates什么意思吧。
    # 不過偶用gvim 6.1試過了,好用!

    :nmap ,i :update<CR>: !start c:\progra~1\intern~1\iexplore.exe <cWORD><CR>
    ----------------------------------------
    # 用VIM編輯ftp文件
    :cmap ,r  :Nread ftp://209.51.134.122/public_html/index.html
    :cmap ,w  :Nwrite ftp://209.51.134.122/public_html/index.html
    # 譯注:原文丟失了開頭的冒號
    # cmap是命令(command)模式綁定

    gvim ftp://209.51.134.122/public_html/index.html
    # 這一句就是開始編輯一個ftp遠端的文件,ft
    ----------------------------------------
    # 附加到一個register (就是用大寫的register名字啦!)
    "a5yy #復制5行到a中
    10j   #下移10行
    "A5yy #再添加5行到a中
    ----------------------------------------
    [I     : 顯示光標處的狹義字可以匹配的行(高級指令)
    # 譯注:# 可以全文查找與光標處的狹義字相匹配的字,
    # 這在查找函數原型和實現,或者變量使用的時候很有用
    ----------------------------------------
    # 常規縮進
    :'a,'b>>
    # 譯釋:把mark a到mark b之間的內容進行兩次縮進

    # 在visual模式下縮進 (無限可重復)
    :vnoremap < <gv
    # 譯釋::vnoremap 重定義了visual模式下 < 符號的含義
    # 把它定義成 <gv
    # 即:先<向外縮進,然后gv重新選擇上一次選擇了的區域
    # 這樣在visual模式下就可以實現連續按<而連續縮進了
    :vnoremap > >gv
    # 同里,內縮
    ----------------------------------------
    # 查找(譯注:建議先學習正則表達式)
    # 譯注:查找命令不用進入:命令模式,直接按/就可以了
    # 如果沒有修飾,可以不要右邊的/
    # 和smth bbs差不多啦,呵呵
    /joe/e                      : 光標停留在匹配單詞最后一個字母處
    /joe/e+1                    : 光標停留在匹配單詞最后一個字母的下一個字母處
    /joe/s                      : 光標停留在匹配單詞第一個字母處
    /^joe.*fred.*bill/          : ft,標準正則表達式
    /^[A-J]\+/                  : 找一個以A~J中一個字母重復兩次或以上開頭的行
    /forum\(\_.\)*pent          : 多行匹配
    /fred\_s*joe/i              : 中間可以有任何空白,包括換行符\n
    # 譯注:這個和perl不太一樣的哦
    /fred\|joe                  : 匹配FRED或JOE
    /\<fred\>/i                 : 匹配fred,fred必須是一個獨立的單詞,而不是子串
    # 譯注:這和perl也不太一樣,perl是用\b做單詞定界符的
    /\<\d\d\d\d\>               : 匹配4個數字
    \<\d\{4}\>                  : 也是匹配4個數字
    # 在visual模式下查找
    :vmap g/ y/<C-R>"<CR>       : 匹配選中的高亮文字
    # 譯釋:vmap是在visual模式下的鍵盤映射
    # 映射了g/這個命令組合
    # y 把選中的高亮文字寫入匿名register "
    # / 打開搜索模式
    # <C-R> 準備粘貼register
    # " 粘貼了""中的內容
    # <CR> 回車,執行

    :vmap <silent> g/    y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR> : with spec chars
    # 譯釋:@#$&^*@#%&*#$@!

    # 跨行匹配,\_ 表示允許匹配換行符,或者說,允許匹配新行
    # 譯注:小心,和perl不一樣
    /<!--\_p\{-}-->                   : 匹配多行注釋
    /fred\_s*joe/i                    : 似乎上面有了,ft
    /bugs\(\_.\)*bunny                : 中間可以有無數東西
    :h \_                             : 看看關于 \_ 的幫助

    # 查找當前光標位置所在子例程/函數(subroutine/function)的聲明
    :nmap gx yiw/^\(sub\<bar>function\)\s\+<C-R>"<CR>
    # 譯釋:nmap 做一個normal模式下的鍵盤綁定
    # y 進入復制狀態,后面需要一個motion
    # 接著就用 iw 指出了這個motion,是inner word
    # inner word也是狹義字<cword>,但是和 w 不同
    # w 是從光標位置開始向后看
    # 而inner word總是把光標移到第一個字母,從而總能得到一個完整的狹義字
    # 試一試 gUw 和 gUiw 就知道區別了,呵呵。

    # 在多個文檔中搜索
    :bufdo /searchstr
    :argdo /searchstr
    ----------------------------------------
    # 替換
    # 譯注:替換命令需要先進入:命令模式
     
    :%s/fred/joe/igc            : 一個常見的替換命令,修飾符igc和perl中一樣意思

    :%s/\r//g                   : 刪除DOS方式的回車^M
    :%s=  *$==                  : 刪除行尾空白
    :'a,'bg/fred/s/dick/joe/igc : 非常有用!(ft,又來了!)
    # 譯釋:'a,'b指定一個范圍:mark a ~ mark b
    # g//用一個正則表達式指出了進行操作的行必須可以被fred匹配
    # 看后面,g//是一個全局顯示命令
    # s/dick/joe/igc則對于這些滿足條件的行進行替換

    # 列復制
    # 譯注:@#%&^#*^%#$!
    :%s= [^ ]\+$=&&=            : 復制最后一列
    :%s= \f\+$=&&=              : 一樣的功能
    :%s= \S\+$=&&               : ft,還是一樣
    # 反向引用,或稱記憶
    :s/\(.*\):\(.*\)/\2 :  \1/  : 顛倒用:分割的兩個字段
    :%s/^\(.*\)\n\1/\1$/        : 刪除重復行
    # 非貪婪匹配,\{-}
    :%s/^.\{-}pdf/new.pdf/      : 只是刪除第一個pdf
    # 跨越可能的多行
    :%s/<!--\_.\{-}-->//        : 又是刪除多行注釋(咦?為什么要說“又”呢?)
    :help /\{-}                 : 看看關于 非貪婪數量符 的幫助
    :s/fred/<c-r>a/g            : 替換fred成register a中的內容,呵呵
    # 寫在一行里的復雜命令
    :%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/
    # 譯注:就是用 | 管道啦

    # 或者
    :%s/suck\|buck/loopy/gc     : 或者(或者需要\,ft!,|不是或者)
    # ft, \不就是轉義了么!這個和perl真是不同了!

    # 調用VIM函數
    :s/__date__/\=strftime("%c")/ : 插入時間串

    # 處理列,替換所有在第三列中的str1
    :%s:\(\(\w\+\s\+\)\{2}\)str1:\1str2:

    # 交換第一列和最后一列 (共4列)
    :%s:\(\w\+\)\(.*\s\+\)\(\w\+\)$:\3\2\1:

    # filter all form elements into paste register
    # 把所有的form元素(就是html里面的form啦)放到register里?
    # ft, 頭疼,不解釋了
    :redir @*|sil exec 'g#<\(input\|select\|textarea\|/\=form\)\>#p'|redir END
    :nmap ,z :redir @*<Bar>sil exec 'g@<\(input\<Bar>select\<Bar>textarea\<Bar>/\=fo
    ----------------------------------------
    # 全局(global)顯示命令,就是用 :g+正則表達式
    # 譯釋: :g/{pattern}/{cmd} 就是全局找到匹配的行
    # 然后對這些行執行命令{cmd}
    :g/\<fred\>/                : 顯示所有能夠為單詞fred所匹配的行
    :g/<pattern>/z#.5           : 顯示內容,還有行號,呵呵
    :g/<pattern>/z#.5|echo "=========="  : 漂亮的顯示,ft!

    # 全局命令 (其他)
    :g/^\s*$/d                  : 刪除所有空行
    :g!/^dd/d                   : 刪除不含字串'dd'的行
    :v/^dd/d                    : 同上
    # 譯釋:v == g!,就是不匹配!
    :g/fred/,/joe/d             : not line based (very powerfull)
    :v/./.,/./-1join            : 壓縮空行
    :g/^$/,/./-j                : 壓縮空行
    :g/<input\|<form/p          : 或者 要用\|
    :g/^/pu _                   : 把文中空行擴增一倍 (pu = put)
                                : 即:原來兩行間有一個空行,現在變成2個
    :g/^/m0                     : 按行翻轉文章 (m = move)
    :g/fred/t$                  : 拷貝行,從fred到文件末尾(EOF)
    :%norm jdd                  : 隔行刪除
    # 譯釋:% 指明是對所有行進行操作
    # norm指出后面是normal模式的指令
    # j是下移一行,dd是刪除行

    # incrementing numbers
    :.,$g/^\d/exe "norm! \<c-a>" : 增加在BOL(beginning of line)處的數字
    # 譯注:.,$ 指明命令從當前行執行到最后一行
    # 如果沒有 .,$ 限定范圍,那么g//就會對整個文件進行操作
    # exe 是執行后面的命令組合

    :.,$g/^\d/exe "norm \<c-p>"  : Win32下必須重定義Ctrl-A

    # 保存全局命令的結果 (注意必須使用添加模式)
    :g/fred/y A                 : 添加所有為fred所匹配的行到register a
    :'a,'b g/^Error/ . w >> errors.txt

    # 復制每一行,然后在復制出來的每一行兩側加上一個 print '復制出來的內容'
    :g/./yank|put|-1s/'/"/g|s/.*/Print '&'/
    ----------------------------------------
    # 全局命令和替換命令聯姻 (強大的編輯能力)
    :'a,'bg/fred/s/joe/susan/gic : 可以使用反向引用來匹配
    :g/fred/,/joe/s/fred/joe/gic :  non-line based (ultra)
    ----------------------------------------
    # 先找fred,然后找joe,然后#$^$%^#$%^@%^%&%^*!
    :/fred/;/joe/-2,/sid/+3s/sally/alley/gIC
    ----------------------------------------
    # 重定向到register * 和 粘貼register *
    :redir @*                    : 重定向命令的輸出結果(最下方命令行上的結果)
                                 : 到register * (ft,* 代表0~1,a~z,..)
    :redir END                   : 結束重定向
    # 處理粘貼
    "*yy                         : 上面講過了,就是復制到register *中
    "*p                          : 然后貼出來
    ----------------------------------------
    :redir >> out.txt            : 重定向到一個文件
    ----------------------------------------
    # 重新格式化文本
    gq<CR>
    gqap  (a是motion p是段落(visual模式))
    ggVGgq  重新格式化整個文章
    ----------------------------------------
    # 對多個文檔實施命令
    :argdo %s/foo/bar/           : 對所有:args列表中的文檔執行命令
    :bufdo %s/foo/bar/
    :windo %s/foo/bar/
    :argdo exe '%!sort'|w!       : 使用外部命令
    ----------------------------------------
    # 命令行的一些好玩的東東
    gvim -h                    : 啟動的時候啟動幫助(Win32)
    vi -h 或 vim -h            : 這個是unix下用
    ls | gvim -                : 編輯一個數據流!
    gvim -o file1 file2        : 以分割窗口打開兩個文件

    # 指出打開之后執行的命令
    gvim.exe -c "/main" joe.c  : 打開joe.c,然后跳轉到'main'

    # 對一個文件執行多個命令
    vim -c "%s/ABC/DEF/ge | update" file1.c

    # 對一組文件執行多個命令
    vim -c "argdo %s/ABC/DEF/ge | update" *.c

    # 自動編輯文件 (編輯命令序列Ex commands已經包含在convert.vim中了)
    vim -s "convert.vim" file.c

    # 不要加載.vimrc和任何plugins (啟動一個干凈的VIM)
    gvim -u NONE -U NONE -N
    ----------------------------------------
    # GVIM 不同的地方
    gvim -d file1 file2        : vimdiff (比較不同)
    dp                         : 把光標處的不同放到另一個文件
    do                         : 在光標處從另一個文件取得不同
    ----------------------------------------
    # Vim陷阱
    # 在vim的正則表達式中, + 和 | 都必須加轉義符 \
    # 小心,這和perl不一樣!
    /fred\+/      : 匹配fred或freddy但是不匹配free
    ----------------------------------------
    # \v ,或叫做very magic (通常都是這么叫)可以取消轉義符
    /codes\(\n\|\s\)*where  : 普通的正則表達式
    /\vcodes(\n|\s)*where   : very magic,| 不用加 \ 了!
    ----------------------------------------
    # 把東西送到命令行/搜索行 (SUPER:偶不再翻譯這種嘆詞了)
    <C-R><C-W>              : 送一個狹義詞
    <C-R><C-A>              : 送一個廣義詞
    <C-R>-                  : 送一個小型刪除寄存器register
    <C-R>[0-9a-z]           : 送一個命名寄存器register
    <C-R>%                  : 送文件名過去 (#也行)
    ----------------------------------------
    # 操作寄存器
    :let @a=@_              : 清除register a
    :let @*=@a              : 寄存器賦值
    :map   <f11> "qyy:let @q=@q."zzz"
    # 譯注:猜猜這個無聊的綁定是什么意思?
    ----------------------------------------
    # 關于幫助的幫助
    :h quickref             : 翻到VIM Quick Reference頁(有用!)
    :h tips                 : Vim自己的tips
    :h visual<C-D><tab>     : 得到一個關于visual關鍵字的幫助列表
                            : 然后用tab鍵去選擇
    :h ctrl<C-D>            : 顯示所有關于Ctrl的幫助
    :h :r                   : :ex冒號命令
    :h CTRL-R               : 普通模式命令
    :h \r                   : \r在正則表達式中是什么意思呢?
    :h i_CTRL-R             : insert模式下的Ctrl-R
    :h c_CTRL-R             : 命令行(command-line)模式下的Ctrl-R
    :h v_CTRL-V             : visual模式下的Ctrl-V
    :h tutor                : VIM 指南
    gvim -h                 : 關于 VIM 命令的幫助
    vi/vim -h
    <C-S>T                  : Control Shift T go backwards in help
                            : 偶不清楚有什么用:(
    ----------------------------------------
    # 選項設置在哪里?
    :scriptnames            : 列出所有加載的 plugins, _vimrcs
    :verbose set history    : 顯示history的值并指出設置文件的位置
    ----------------------------------------
    # 制作你自己的VIM幫助
    :helptags /vim/vim61/doc  : 重建 /doc 中所有的 *.txt 幫助文件
    :help add-local-help
    ----------------------------------------
    # 用外部程序來運行程序 (例如 perl :)
    map   <f2>   :w<CR>:!perl -c %<CR>
    # 譯釋::w<CR>寫文件
    # :!perl -c %<CR>用perl來運行當前文件
    # 當前文件必須有文件名!
    ----------------------------------------
    # 插入DOS換行符
    :%s/nubian/<C-V><C-M>&/g          :  Ctrl-V是一種轉義,它說要解釋<C-M>
    :%s/nubian/<C-Q><C-M>&/g          :  對于Win32應該這樣
    :%s/nubian/^M&/g                  :  你看到的^M是一個字符
    :%s/nubian/\r&/g                  :  更好的形式
    ----------------------------------------
    # 把最后一個命令貼到當前位置
    i<c-r>:
    # 把最后一個搜索指令貼到當前位置
    i<c-r>/
    # 譯釋:i是進入insert模式,
    # Ctrl-r是開啟插入模式下register的引用
    # :和/分別引用了兩個register的內容
    ----------------------------------------
    # 更多的完成功能
    <C-X><C-F>                        :插入當前目錄下的一個文件名到當前位置
    # 在insert模式下使用
    # 然后用 Ctrl-P/Ctrl-N 翻頁
    ----------------------------------------
    # 替換一個visual區域
    # 選擇一個區域,然后輸入 :s/Emacs/Vim/ 等等,vim會自動進入:模式
    :'<,'>s/Emacs/Vim/g               : 前面的'<,'>是vim自動添加的
    ----------------------------------------
    # 在文件中插入行號(不是顯示行號,是插入!)
    :g/^/exec "s/^/".strpart(line(".")."    ", 0, 4)
    ----------------------------------------
    # 用VIM的方式來編號行

    :set number                       :顯示行號
    :set nonu                         :取消顯示
    :%s/^/\=strpart(line('.')."        ",0,&ts)

    #從任意行開始編號(需要perl,嘿嘿)
    :'a,'b!perl -pne 'BEGIN{$a=223} substr($_,2,0)=$a++'
    #似乎有點小問題,你試試看:)

    qqmnYP`n^Aq                       : 記錄到q 然后用 @q 重復
    #似乎不能工作,你試試看:)

    # 遞增已存在數字到文件末
    :.,$g/^\d/exe "normal! \<c-a>"

    # 高級遞增,看:
    http://vim.sourceforge.net/tip_view.php?tip_id=150
    ----------------------------------------
    # 高級遞增 ("真的很有用",ft)
    " 把下面幾句放到 _vimrc #vimrc腳本用 " 做行注釋符
    let g:I=0
    function! INC(increment)
    let g:I =g:I + a:increment
    return g:I
    endfunction
    " 例如從mark a 到mark b 遞增,從223開始,步長為5
    :let I=223
    :'a,'bs/$/\=INC(5)/
    " (原文:create a map for INC) 
    " 但是cab是清楚命令行縮寫啊?怎么回事?
    cab viminc :let I=223 \| 'a,'bs/$/\=INC(5)/
    ----------------------------------------
    # 加密(小心使用,不要忘了密碼)
    :X                                : 然后vim會提示你輸入密碼
    :h :X
    ----------------------------------------
    # 模式行(modeline)
    # 第二版新加,感謝tcpip
    vim:noai:ts=2:sw=4:readonly: #讓文檔只讀
    # 譯釋:這一行必須以vim:開頭,而且只能在文檔的前5行或后5行之內
    # 后面是需要執行的命令,依次是:
    # noai       noautoindent 
    # ts=2       tabstop=2
    # sw=4       shiftwidth=4
    # readonly   readonly

    :h modeline #看看關于modeline的幫助先!
    ----------------------------------------
    # Creating your own GUI Toolbar entry
    # 對于text模式下的vim沒用,不翻了
    amenu  Modeline.Insert\ a\ VIM\ modeline <Esc><Esc>ggOvim:ff=unix ts=4 ss=4<CR>v
    ----------------------------------------
    # 一個保存當前光標下的狹義字到一個文件的函數
    function! SaveWord()  "這里用!是強制覆蓋以前的定義
       normal yiw
       exe ':!echo '.@0.' >> word.txt'
    endfunction
    map ,p :call SaveWord() #使用該函數的一個例子
    ----------------------------------------
    # 刪除重復行的函數
    function! Del()
     if getline(".") == getline(line(".") - 1)
       norm dd
     endif
    endfunction

    :g/^/ call Del() #使用該函數的一個例子
    ----------------------------------------
    # 雙字節編碼 (non alpha-numerics)
    :digraphs                         : 顯示編碼表
    :h dig                            : 幫助
    i<C-K>e'                          : 輸入 é
    i<C-V>233                         : 輸入 é (Unix)
    i<C-Q>233                         : 輸入 é (Win32)
    ga                                : 查看字符的hex值
    ----------------------------------------
    # 文件名自動完成 (例如 main_c.c)
    :e main_<tab>                     : tab 鍵完成
    gf                                : 打開光標處廣義字命名的文件 (normal模式)
    main_<C-X><C-F>                   : 文件名自動完成(insert模式)

    ----------------------------------------
    # Vim復雜使用
    # 交換兩個單詞
    :%s/\<\(on\|off\)\>/\=strpart("offon", 3 * ("off" == submatch(0)), 3)/g
    ----------------------------------------
    # 把text文件轉換成html文件(oh,ft)
    :runtime! syntax/2html.vim        : 轉換 txt 成 html
    :h 2html                          : 看看幫助
    ----------------------------------------
    # VIM 有一個內部自帶的 grep 命令
    :grep some_keyword *.c            : 得到一個包含some_keyword的c文件名列表
    :cn                               : 去下一個出現的位置
    ----------------------------------------
    # 強制無后綴文件的語法著色方式 .pl
    :set syntax=perl
    # 取消語法著色
    :set syntax off
    # 改變色彩主題 (在~vim/vim??/colors中的任何文件)
    :colorscheme blue
    ----------------------------------------
    :set noma (non modifiable)        : 防止修改
    :set ro (Read Only)               : 只讀保護
    ----------------------------------------
    # Sessions (打開一系列文件)
    gvim file1.c file2.c lib/lib.h lib/lib2.h :在"session"中加載一系列文件
    :mksession                        : 生成一個Session文件 (默認是Session.vim)
    :q
    gvim -S Session.vim               : 重新讀取一個session,也就讀取了所有文件,ft
    ----------------------------------------
    # 標記(tags) (跳轉到subroutines/functions)
    taglist.vim                       : 最流行的插件
    :Tlist                            : 顯示Tags (functions的列表)
    <C-]>                             : 跳轉到光標處的function
                                      : 這個鍵 Ctrl-] 和vim幫助中是一樣的
    ----------------------------------------
    # Just Another Vim Hacker JAVH
    # Juat Another Perl Hacker JAPH,嘿嘿
    vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"
    # 譯釋:呵呵,誰來解釋一下吧!
    # 其實不過是在啟動vim的時候執行了一個命令
    # 先寫入了 Just Another Vim Hacker 的rot13編碼
    # 然后再解碼
    ----------------------------------------
    終于翻完了,呵呵。好累啊!
    __END__
    posted on 2011-08-05 17:03 MEYE 閱讀(10893) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 久久久久亚洲AV无码专区首| 国产在线精品一区免费香蕉| 亚洲成a人片在线观看中文动漫| 四虎永久免费地址在线观看| 成人女人A级毛片免费软件| 国产啪精品视频网站免费尤物| 在线播放亚洲精品| 亚洲国产激情在线一区| 久久久久亚洲AV无码麻豆| 美腿丝袜亚洲综合| 亚洲?v无码国产在丝袜线观看| 亚洲综合日韩久久成人AV| 我要看WWW免费看插插视频| 久久国产精品成人片免费| 三年片免费高清版| 一本久久免费视频| 美女免费精品高清毛片在线视| 亚洲成_人网站图片| 亚洲av成人综合网| 91亚洲自偷在线观看国产馆| 亚洲综合图片小说区热久久| 久久亚洲一区二区| 亚洲成a人片77777kkkk| 亚洲人色婷婷成人网站在线观看| 亚洲精品成人a在线观看| 免费国产在线观看| 无码国产亚洲日韩国精品视频一区二区三区 | 亚洲欧美国产日韩av野草社区| 亚洲精品中文字幕乱码影院| 亚洲色四在线视频观看| 亚洲国产天堂久久综合网站 | 国产无遮挡裸体免费视频在线观看| igao激情在线视频免费| 有色视频在线观看免费高清在线直播 | 国产大陆亚洲精品国产| 日日摸日日碰夜夜爽亚洲| 亚洲Aⅴ在线无码播放毛片一线天| 亚洲精品人成网线在线播放va| 亚洲人成网亚洲欧洲无码| 亚洲国产成人精品无码区花野真一| 亚洲heyzo专区无码综合|