2009年6月29日 星期一

個人vim常用指令列表

command


"常用指令 "[K] "函式查詢 "若您在 VIM 中撰寫 C/C++ 程式,可以在 C/C++ 標準函式厙提供的函式名字上按「K」,便可以呼叫出 man page "[=] "自動程式縮排對齊 "若您在 VIM 中撰寫 C/C++ "程式,可以利用「gg」指令將游標移到視窗最上方、利用「v」切換到選取模式、再用「G」將游標移到檔案尾端 "(即達到全選的功能),最後按「=」,VIM 便會幫你的程式做自動對齊 "[:set all] "顯示所有vim支援的參數 "[:version] "顯示讀取的vimrc順序和路徑 set [cmd]? 查看這個指令的目前設定 補全 CTRL-X CTRL-L 整行补全 CTRL-X CTRL-N 根据当前文件里关键字补全 CTRL-X CTRL-K 根据字典补全 CTRL-X CTRL-T 根据同义词字典补全 CTRL-X CTRL-I 根据头文件内关键字补全 CTRL-X CTRL-] 根据标签补全 CTRL-X CTRL-F 补全文件名 CTRL-X CTRL-D 补全宏定义 CTRL-X CTRL-V 补全vim命令 CTRL-X CTRL-U 用户自定义补全方式 CTRL-X CTRL-S 拼写建议 gQ 進入 Ex 模式,輸入 visual 可以返回正常模式。可以按tab補完 qq 打開紀錄器,再按一次q關閉紀錄,紀錄中無法使用下列查詢歷史指令 q: 打開Ex command-line視窗必且列出所有Ex歷史指令 q/ 打開一個視窗顯示紀錄過的搜尋字串 q? 同上 多窗口命令(:h q_wi) CTRL-W s 或 :split 将窗口分割成两部分 (split) :split {file} 分隔窗口并在其中一个编辑 {file} CTRL-W v 或 :vsplit 将窗口分割成两部分 (vsplit) :vsplit {file} 同上,但垂直分割 :vertical {cmd} 使命令 {cmd} 垂直分割 :sf[ind] {file} 分割窗口,从 {path} 中找到文件 {file} 并编辑之。 CTRL-W ] 分割窗口并跳转到光标下的标签 CTRL-W f 分割窗口并编辑光标下的文件名 (file) CTRL-W ^ 分割窗口并编辑轮换文件 CTRL-W n 或 :new 创建新空白窗口 (new) CTRL-W q 或 :q[uit] 退出编辑并关闭窗口 (quit) CTRL-W c 或 :cl[ose] 隐藏当前缓冲区并关闭窗口 (close) CTRL-W o 或 :on[ly] 使当前窗口成为唯一窗口 (only) CTRL-W j 跳转到下方窗口 CTRL-W k 跳转到上方窗口 CTRL-W CTRL-W 移动光标至下方窗口 (折转) (Wrap) CTRL-W W 移动光标至上方窗口 (折转) (wrap) CTRL-W t 跳转到顶端窗口 (top) CTRL-W b 跳转到底端窗口 (bottom) CTRL-W p 跳转到上一次激活的窗口 (previous) CTRL-W r 向下旋转窗口 (rotate) CTRL-W R 向上旋转窗口 (Rotate) CTRL-W x 将当前窗口与下一个窗口对调 (eXchange) CTRL-W = 使所有窗口等高 CTRL-W - 减少当前窗口高度 CTRL-W + 增加当前窗口高度 CTRL-W _ 设置当前窗口高度 (缺省: 很高) 折叠(:h q_fo) set foldmethod=manual 手动折叠 set foldmethod=indent 按照缩进折叠 set foldmethod=expr 按照表达式 'foldexpr' 折叠 set foldmethod=syntax 按照语法区域折叠 set foldmethod=marker 按照标志 'foldmarkers' 折叠 zf{motion} 操作符: 手动定义一个折叠 (fold) :{range}fold 将范围 {range} 包括的行定义为一个折叠 zd 删除光标下的一个折叠 (delete) zD 删除光标下的所有折叠 (Delete) zo 打开光标下的折叠 (open) zO 打开光标下的所有折叠 (Open) zc 关闭光标下的一个折叠 (close) zC 关闭光标下的所有折叠 (Close) zm 折起更多: 减少 'foldlevel' (more) zM 关闭所有折叠: 置 'foldlevel' 为 0 zr 减少折叠: 增加 'foldlevel' (reduce) zR 打开所有折叠: 置 'foldlevel' 为最大 zn 不折叠: 复位 'foldenable' (none) zN 正常折叠: 置位 'foldenable' (Normal) zi 反转 'foldenable' (invert) diff使用(:h diff) command line進入diff模式 vimdiff file1 file2 [file3 [file4]] 或 vim -d file1 file2 [file3 [file4]] 已在Vim中时,你可以用3种方式进入 diff 模式。 :diffsplit {filename} *:diffs* *:diffsplit* 对 {filename} 开一个新窗口。当前的和新开的窗口被设定了和 "vimdiff" 一样的参数。参考 'diffexpr'。 *:difft* *:diffthis* :diffthis 使当前窗口成为 diff 窗口的一部分。设定了和 "vimdiff" 同样的 参数。 :diffpatch {patchfile} *:diffp* *:diffpatch* 使用当前的缓冲,用 {patchfile} 给它打上补丁并打开一个缓冲显示 结果。设定了和 "vimdiff" 同样的参数。 {patchfile} 可以是任何一种 "patch" 程序认识的或 'patchexpr' 可以处理的格式。 备注: {patchfile} 只能包含一个文件的比较结果,即当前文件的。如 果 {patchfile} 也包含了其他文件的比较,结果将不可预知。Vim 改 变目录到 /tmp 以避免当前目录被意外的打补丁。但它仍可能导致若干 ".rej" 文件产生。当绝对路径名出现时,这些文件可能被打补丁。 要垂直分割窗口,加上 |:vertical|。如: :vert diffsplit main.c :vert diffpatch /tmp/diff 但你改变文本时,Vim 试图使比较保持更新。插入或删除行一般会使 diff 正确的更新。 在一行里的改动和更复杂的改动将不会使比较更新。要强制刷新比较使用: :diffupdate 有两条命令可用于在 diffs 之间跳转: [c 向后至上一个更改的开始。当加上个数字后,便重复执行相应 次。 ]c 向前至下一个更改的开始。当加上个数字后,便重复执行相应 次。 拷貝diffs :[range]diffg[et] [bufspec] 用另一个缓冲来修改当前的缓冲,消除不同之处。如果给定 [bufspec],就使用该缓冲。否则,它仅当有另一个在 diff 模式下 的缓冲时才起作用。 [range] 参考下面。 :[range]diffpu[t] [bufspec] 用当前缓冲来修改另一个缓冲,消除不同之处。就象 ":diffget" 但更改的是另一个缓冲,而不是当前的。 [range] 参考下面。 do 同 ":diffget" 但没有参数和范围。"o" 表示 "obtain" ("dg" 是不能这样使用的。那可能是 "dgg" 的开始!)。 dp 同 ":diffput" 但没有参数和范围。 参数 [bufspec] 可以是一个缓冲的序号,一个缓冲名称或缓冲名称的一部分的模式,如: :diffget 使用另一个进入 diff 模式的缓冲 :diffget 3 使用3号缓冲 :diffget v2 使用缓冲名同 "v2" 匹配的,并进入 diff 模式的( 如,"file.c.v2") 正規表示式(:help pattern) 用:grep或vimgrep來查找檔案內容 :cd ~/src/vim70 :vimgrep /\<main\>/ ./*.c 查所有目前目錄下的.c檔,中含有main的位置 :cw 開啟 要恢复上次的编辑环境,我们需要保存两种不同的信息,一种是会话(session)信息,另外一种是viminfo信息。 * 会话信息中保存了所有窗口的视图,外加全局设置。 * viminfo信息中保存了命令行历史(history)、搜索字符串历史(search)、输入行历史、非空的寄存器内容(register)、文件的位置标记(mark)、最近搜索/替换的模式、缓冲区列表、全局变量等信息。 :mksession [file] '貯存session文件 :source [file] '载入会话文件 :wviminfo [file] '貯存viminfo文件 :rviminfo [file] '读入viminfo文件 :h 'sessionoptions' session file中貯存哪些訊息,是由sessionoptions決定的 :h 21.3 :wviminfo貯存哪些內容與保存的數量,由viminfo決定 ' specify how many files for which you save marks (a-z) f option controls whether global marks (A-Z and 0-9) are stored < option controls how many lines are saved for each of the registers : number of lines to save from the command line history @ number of lines to save from the input line history / number of lines to save from the search history r removable media, for which no marks will be stored (can be used several times) ! global variables that start with an uppercase letter and don't contain lowercase letters h disable 'hlsearch' highlighting when starting % the buffer list (only restored when starting Vim without file arguments) c convert the text using 'encoding' n name used for the viminfo file (must be the last option) quickfix :set makeprg=gcc\ -Wall\ -ohello\ hello.c :make 經過上面步驟產生error可以用下面的顯示 :cc 显示目前指到详细错误信息 ( :help :cc ) :cp 跳到上一个错误 ( :help :cp ) :cp :cprevious :cn 跳到下一个错误 ( :help :cn ) :cN :cNext :cl 列出所有错误 ( :help :cl ) :cl :clist :cw 如果有错误列表,则打开quickfix窗口 ( :help :cw ) :cw :cwindow :col 到前一个旧的错误列表 ( :help :col ) :colder :col :cnew 到后一个较新的错误列表 ( :help :cnew ) :cnewer :cnew 產生html格式的.vimrc :runtime! syntax/2html.vim

note


a.vim : Alternate Files quickly (.c --> .h etc) [ 版本與更新日期 ] a.vim 2.18 2007-06-07 [ 插件的功能 ] A few of quick commands to swtich between source files and header files quickly. [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=31 [ 備註或特別提醒 ] bufexplorer.zip : Buffer Explorer / Browser [ 版本與更新日期 ] bufexplorer.zip 7.2.2 2008-11-19 [ 插件的功能 ] 列出目前開啟的buffer,可以很容易切換或刪除buffer. 有了tab似乎不在這麼需要 :tab ball (可以把所有buffer轉成tab開啟) [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=42 c.vim : C/C++ IDE -- Write and run programs. Insert statements, idioms, comments etc. [ 版本與更新日期 ] cvim.zip 5.5 2009-02-17 [ 插件的功能 ] 自動compile和run還有簡易輸入各種statements和comments [ 插件的下載地址 ] http://vim.sourceforge.net/scripts/script.php?script_id=213 cscope_maps.vim [ 版本與更新日期 ] [ 插件的功能 ] 可以使用<C-]>和<C-T>的熱鍵來收尋c變數的定義與使用的檔案位置 [ 插件的下載地址 ] http://cscope.sourceforge.net/cscope_maps.vim ctags http://ctags.sourceforge.net (可apt-get install) cscope http://cscope.sourceforge.net/ (可apt-get install) [ 備註或特別提醒 ] 需安裝ctags 需安裝cscope taglist.vim : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc) [ 版本與更新日期 ] taglist_45.zip 4.5 2007-09-21 [ 插件的功能 ] 實現類或者函數列表功能,支持 C/C++, Java, Perl, Python, TCL, SQL, PHP 等語言,它可以在VIM中創建一個窗口,列出編輯的源文件中的類、 函數、變量定義列表,而且更方便的是這個列表 也插入在了右鍵菜單中,分類存放, 訪問非常方便。 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=273 [ 備註或特別提醒 ] 依賴於 Exuberant Ctags,可以在 http://ctags.sourceforge.net 下載。 mru.vim : Plugin to manage Most Recently Used (MRU) files [ 版本與更新日期 ] mru.vim 3.2 2008-09-23 [ 插件的功能 ] manage Most Recently Used (MRU) files [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=521 genutils : General utility functions [ 版本與更新日期 ] genutils-2.4.zip 2.4 2007-06-12 [ 插件的功能 ] The new version requires Vim 7.0 and it employs the new autoload mechanism. 所以有些新的套件需要用這個plugin裡的函式 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=197 lookupfile : Lookup files using Vim7 ins-completion [ 版本與更新日期 ] lookupfile-1.8.zip 1.8 2007-09-13 [ 插件的功能 ] [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1581 [ 備註或特別提醒 ] 需要安裝genutils.vim netrw.vim : Network oriented reading, writing, and browsing (keywords: netrw ftp scp) [ 版本與更新日期 ] netrw.vba.gz 135 2009-01-14 (vim 7.0有預設安裝) [ 插件的功能 ] Netrw supports reading and writing files across networks. Browsing directories. [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1075 [ 備註或特別提醒 ] 最新版要vim7.2才能裝 [ 版本與更新日期 ] [ 插件的功能 ] [ 插件的下載地址 ] [ 備註或特別提醒 ] SuperTab continued. : Do all your insert-mode completion with Tab. [ 版本與更新日期 ] supertab.vim 0.49 2009-02-05 [ 插件的功能 ] 自动补全直接按Tab就好了,想bash shell一样 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1643 CRefVim : a C-reference manual especially designed for Vim [ 版本與更新日期 ] crefvim.zip 1.0.4 2004-11-28 [ 插件的功能 ] crefvim 查阅C语言参考手册,所有库函数的标准说明。 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=614 [ 備註或特別提醒 ] 第一次使用需輸入:helptags ~/.vim/doc ManPageView : Viewer for manpages, gnu info, perldoc, and php (unix/linux/cygwin) [ 版本與更新日期 ] manpageview.vba.gz 22 2008-11-26 7.2 [ 插件的功能 ] manpageview 在vim中查看manpage [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=489 word_complete.vim : automatically offers word completion as you type [ 版本與更新日期 ] word_complete.vim 1.1 2006-12-06 [ 插件的功能 ] Insert模式下在輸入的時候自動補全單詞,如果補全正確可以按Tab鍵接受, 否則可以不管它繼續輸入或者按Ctrl-n, Ctrl-p切換補全。 注意是輸入三個字符後才開始補全。 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=73 Mark : a little script to highlight several words in different colors simultaneously [ 版本與更新日期 ] mark.vim 1.1.8-g 2008-04-25 [ 插件的功能 ] 顯示多個serach的結果,用不同的顏色,提供類似*和#的功能熱鍵 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1238 MultipleSearch : Highlight multiple searches at the same time, each with a different color. [ 版本與更新日期 ] MultipleSearch.zip 1.3 2008-09-23 [ 插件的功能 ] 顯示多個serach的結果,用不同的顏色 [ 插件的下載地址 ] http://www.vim.org/scripts/download_script.php?src_id=9276 SearchComplete : Tab completion of words inside of a search ('/') [ 版本與更新日期 ] SearchComplete.vim 1.1 2002-11-08 [ 插件的功能 ] 按tab自動補齊search字串 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=474 FencView.vim : Autodetect multiple encodings [ 版本與更新日期 ] fencview.vim 4.6 2008-12-11 [ 插件的功能 ] 可以自動偵測檔案的encodings [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1708 number marks : showing marks using number array in color, easy to trace. [ 版本與更新日期 ] marks_corey.zip 1.2 2008-04-14 [ 插件的功能 ] 這個腳本顯示用帶顏色的數字標明的marks,並且向前或者向後移動。 可以保存到文件,下次可以重現原來在多個文件裡面的marks。 比較清晰顯示你標記的代碼在前後的位置,有數字嘛! [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=2194    matrix.vim : Matrix screensaver for VIM [ 版本與更新日期 ] matrix.vim 1.10 2008-05-14 [ 插件的功能 ] 駭客任務的入侵畫面,還蠻有趣的,當作螢幕保護程式吧,哈哈 [ 插件的下載地址 ] http://www.vim.org/scripts/script.php?script_id=1189 vcscommand (配合subversion/cvs使用) [ 版本與更新日期 ] [ 插件的功能 ] [ 插件的下載地址 ] [ 備註或特別提醒 ] http://www.vim.org/scripts/script.php?script_id=39 matchit.zip 1.13.2 2008-01-29 [ 版本與更新日期 ] [ 插件的功能 ] [ 插件的下載地址 ] [ 備註或特別提醒 ] http://www.vim.org/scripts/script.php?script_id=90 vcscommand.zip beta29 2009-02-13 [ 版本與更新日期 ] [ 插件的功能 ] [ 插件的下載地址 ] [ 備註或特別提醒 ] http://www.vim.org/scripts/script.php?script_id=1863 tlib.vba.gz 0.31 2009-02-25 7.0 [ 版本與更新日期 ] [ 插件的功能 ] [ 插件的下載地址 ] [ 備註或特別提醒 ] http://www.vim.org/scripts/script.php?script_id=861 Viki.vba.gz 3.11 2009-03-20 need tlib

plugin command


\ : mean it start is a leader , mru.vim (Plugin to manage Most Recently Used (MRU) files) :MRU (list and edit files from the MRU list) o (open the file name under the cursor in the MRU window in a new window) t (open a file from the MRU window in a new tab) u (press the 'u' key in the MRU window to update the file list) q (close the MRU window) :MRU vim (specify a partial file name and only one matching filename is found, then the ":MRU" command will edit that file) :MRU vim<Tab> (enter a partial file name and then press <Tab> to complete file names) :MRU vim<Ctrl-D> (enter a partial file name and then press <Ctrl-D> to list all the matching file names) .vimrc "The list of recently edited file names is stored in the file specified by the MRU_File variable "The default setting for this variable is $HOME/.vim_mru_files for Unix-like systems let MRU_File = 'd:\myhome\_vim_mru_files' "set the 'MRU_Max_Entries' variable to remember more file names let MRU_Max_Entries = 20 "exclude file names matching a list of patterns "you can set the MRU_Exclude_Files variable to a list of Vim regular expressions "not include files in the temporary (/tmp, /var/tmp and d:\temp) directories let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' "add only file names matching a set of patterns to the MRU list "add only .c and .h files to the MRU list let MRU_Include_Files = '\.c$\|\.h$' "The default height of the MRU window is 8 let MRU_Window_Height = 15 "MRU plugin to reuse the current window let MRU_Use_Current_Window = 1 "zero to keep the MRU window open after select a file from MRU let MRU_Auto_Close = 0 "don't use the "File->Recent Files" menu and want to disable it, set it zero let MRU_Add_Menu = 0 a.vim (Alternate Files quickly (.c --> .h etc)) :A switches to the header file corresponding to the current file being edited (or vise versa) :AS splits and switches :AV vertical splits and switches :AT new tab and switches :AN cycles through matches :IH switches to file under cursor :IHS splits and switches :IHV vertical splits and switches :IHT new tab and switches :IHN cycles through matches <Leader>ih switches to file under cursor <Leader>is switches to the alternate file of file under cursor (e.g. on <foo.h> switches to foo.cpp) <Leader>ihn cycles through matches E.g. if you are editing foo.c and need to edit foo.h simply execute :A and you will be editting foo.h, to switch back to foo.c execute :A again. c.vim Alt-F9 write buffer and compile F9 compile and link Ctrl-F9 run executable Shift-F9 command line arguments cscope_maps.vim <C-]> (search the word under cursor) <C-T> (go back to where you were before the search) " 's' symbol: find all references to the token under cursor nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> " 'g' global: find global definition(s) of the token under cursor nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> " 'c' calls: find all calls to the function name under cursor nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> " 't' text: find all instances of the text under cursor nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> " 'e' egrep: egrep search for the word under cursor nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> " 'f' file: open the filename under cursor nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> " 'i' includes: find files that include the filename under cursor nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> " 'd' called: find functions that function under cursor calls nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> cscope -Rbkq -R: 在生成索引文件时,搜索子目录树中的代码 -b: 只生成索引文件,不进入cscope的界面 -k: 在生成索引文件时,不搜索/usr/include目录 -q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度 #!/bin/sh find . -name ”*.h” -o -name ”*.c” -o -name ”*.cc” > cscope.files cscope -bkq -i cscope.files ctags -R "生成tags可以cscope可以與ctags搭配使用 CRefVim : a C-reference manual especially designed for Vim <Leader>cr normal mode: get help for word under cursor Memory aid cr: (c)-(r)eference <Leader>cr visual mode: get help for visually selected text Memory aid cr: (c)-(r)eference <Leader>cw: prompt for word CRefVim should search for Memory aid cw: (c)-reference (w)hat <Leader>cc: jump to table of contents of the C-reference manual Memory aid cc: (c)-reference (c)ontents netrw.vim (:help netrw-browse) Enter the explore mode :NetrwClean[!] ...........................................|netrw-clean| :NetrwSettings ...........................................|netrw-settings| :Explore[!] [dir] Explore directory of current file......|netrw-explore| :Hexplore[!] [dir] Horizontal Split & Explore.............|netrw-explore| :Nexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| :Pexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| :Rexplore Return to Explorer.....................|netrw-explore| :Sexplore[!] [dir] Split & Explore directory .............|netrw-explore| :Texplore[!] [dir] Tab & Explore..........................|netrw-explore| :Vexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| In the explore mode <F1> Causes Netrw to issue help <cr> Netrw will enter the directory or read the file |netrw-cr| <del> Netrw will attempt to remove the file/directory |netrw-del| - Makes Netrw go up one directory |netrw--| a Toggles between normal display, |netrw-a| hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide) c Make browsing directory the current directory |netrw-c| d Make a directory |netrw-d| D Attempt to remove the file(s)/directory(ies) |netrw-D| gb Go to previous bookmarked directory |netrw-gb| gh Quick hide/unhide of dot-files |netrw-gh| gi Display information on file |netrw-qf| <c-h> Edit file hiding list |netrw-ctrl-h| i Cycle between thin, long, wide, and tree listings |netrw-i| <c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-l| mb Bookmark current directory |netrw-mb| mc Copy marked files to marked-file target directory |netrw-mc| md Apply diff to marked files (up to 3) |netrw-md| me Place marked files on arg list and edit them |netrw-me| mf Mark a file |netrw-mf| mh Toggle marked file suffices' presence on hiding list |netrw-mh| mm Move marked files to marked-file target directory |netrw-mm| mp Print marked files |netrw-mp| mr Mark files satisfying a |regexp| |netrw-mr| mt Current browsing directory becomes markfile target |netrw-mt| mT Apply ctags to marked files |netrw-mT| mu Unmark all marked files |netrw-mu| mx Apply arbitrary shell command to marked files |netrw-mx| mz Compress/decompress marked files |netrw-mz| o Enter the file/directory under the cursor in a new |netrw-o| browser window. A horizontal split is used. O Obtain a file specified by cursor |netrw-O| p Preview the file |netrw-p| P Browse in the previously used window |netrw-P| q List bookmarked directories and history |netrw-qb| r Reverse sorting order |netrw-r| R Rename the designed file(s)/directory(ies) |netrw-R| s Select sorting style: by name, time, or file size |netrw-s| S Specify suffix priority for name-sorting |netrw-S| t Enter the file/directory under the cursor in a new tab|netrw-t| u Change to recently-visited directory |netrw-u| U Change to subsequently-visited directory |netrw-U| v Enter the file/directory under the cursor in a new |netrw-v| browser window. A vertical split is used. x View file with an associated program |netrw-x| REMOTE EDITING :e dav://machine[:port]/path uses cadaver :e fetch://[user@]machine/path uses fetch :e ftp://[user@]machine[[:#]port]/path uses ftp autodetects <.netrc> :e http://[user@]machine/path uses http uses wget :e rcp://[user@]machine/path uses rcp :e rsync://[user@]machine[:port]/path uses rsync :e scp://[user@]machine[[:#]port]/path uses scp :e sftp://[user@]machine/path uses sftp REMOTE READING :Nread ? give help :Nread "machine:path" uses rcp :Nread "machine path" uses ftp with <.netrc> :Nread "machine id password path" uses ftp :Nread "dav://machine[:port]/path" uses cadaver :Nread "fetch://[user@]machine/path" uses fetch :Nread "ftp://[user@]machine[[:#]port]/path" uses ftp autodetects <.netrc> :Nread "http://[user@]machine/path" uses http uses wget :Nread "rcp://[user@]machine/path" uses rcp :Nread "rsync://[user@]machine[:port]/path" uses rsync :Nread "scp://[user@]machine[[:#]port]/path" uses scp :Nread "sftp://[user@]machine/path" uses sftp REMOTE WRITING :Nwrite ? give help :Nwrite "machine:path" uses rcp :Nwrite "machine path" uses ftp with <.netrc> :Nwrite "machine id password path" uses ftp :Nwrite "dav://machine[:port]/path" uses cadaver :Nwrite "ftp://[user@]machine[[:#]port]/path" uses ftp autodetects <.netrc> :Nwrite "rcp://[user@]machine/path" uses rcp :Nwrite "rsync://[user@]machine[:port]/path" uses rsync :Nwrite "scp://[user@]machine[[:#]port]/path" uses scp :Nwrite "sftp://[user@]machine/path" uses sftp http: not supported! REMOTE DIRECTORY BROWSING :e [protocol]://[user]@hostname/path/ :Nread [protocol]://[user]@hostname/path/ LOCAL DIRECTORY BROWSING :e /some/path/to/a/directory ctags :tag {ident} "跳转到指定的标签, ident可以是正規表示式 :tags "显示标签栈 CTRL-] "跳转到当前光标下的标签 CTRL-T "跳到标签栈中较早的标签 cd ~/src/vim70 ctags –R src ""在~/src/vim70/目錄下生成一個名為tags的檔案 這個檔案中包含~/src/vim70/src/目錄下所有.c.h檔案的標籤 :cd ~/src/vim70 "切换当前目录为~/src/vim70 :set tags=tags "设置tags选项为当前目录下的tags文件 :tag main "查詢tags中所有含有main的檔案位置 lookupfile.vim : Lookup files using Vim7 ins-completion :LookupFile Lookup files from tag files. :LUBufs Lookup loaded files (buffers) using |bufname()|. :LUWalk Lookup files using |glob()|. 可以用ctags生成的tags文件,但速度較慢 改用下面的script會比較快,輸出仍然是ctags格式 #!/bin/sh # generate tag file for lookupfile plugin echo -e "!_TAG_FILE_SORTED\t2\t/2=foldcase/" > filenametags find . -not -regex '.*\.\(png\|gif\)' -type f -printf "%f\t%p\t1\n" | \ sort -f >> filenametags vim要設定 :let g:LookupFile_TagExpr = '"./filenametags"' (這樣才會改用filenametags,否則預設是tags) SuperTab continued. : Do all your insert-mode completion with Tab. 只要按tab不用按ctrl-N, ctrl-P ManPageView : Viewer for manpages, gnu info, perldoc, and php (unix/linux/cygwin) :Man topic :Man topic booknumber :Man booknumber topic :Man topic(booknumber) word_complete.vim : automatically offers word completion as you type "To activate, choose "Word Completion" from the Tools menu, or type :call DoWordComplete() "To make it stop, choose "Tools/Stop Completion," or type :call EndWordComplete() Mark : a little script to highlight several words in different colors simultaneously Normal \m mark or unmark the word under or before the cursor \r manually input a regular expression \n clear current mark (i.e. the mark under the cursor), or clear all marks Visual \m mark or unmark a visual selection \r manually input a regular expression Searching: Normal \* jump to the next occurrence of current mark \# jump to the previous occurrence of current mark \/ jump to the next occurrence of ANY mark \? jump to the previous occurrence of ANY mark * behaviors vary, please refer to the table on # line 123 MultipleSearch : Highlight multiple searches at the same time, each with a different color. see :h MultipleSearch SearchComplete : Tab completion of words inside of a search ('/') when / search, you can enter tab to make word complete automatically FencView.vim : Autodetect multiple encodings :FencAutoDetect Auto detect the file encoding. Built-in detected encodings: :FencView Open the encoding list window, matrix.vim : Matrix screensaver for VIM :Matrix 開啟此模組 number marks : showing marks using number array in color, easy to trace. 1:make a mark, or delete it: ctrl + F2 mm 2:move to ahead mark: shift + F2 mv 3:move to next mark: F2 mb 4:delete all marks: F4 5:moving a mark: m. (press m. at the one mark, and move the cursor to another line, press m. again. ) " If you want to save the marks to a file. Do it like below: " Put the one line " let g:Signs_file_path_corey='c:\' " into your gvimrc or _vimrc, change it to your path. :call Save_signs_to_file() # Save marks. :call Load_signs_from_file() # reload signs.

2009年6月20日 星期六

My blogger css example

#page



.narrowcolumn




#sidebar .widget


#sidebar .widget-content


#sidebar h2


#kotakkanan


#kotakkanan1




#footer .widget


.date-header


.post-body


.post


.post-title


.post-title a:hover只是把原本的功能加上hover的功能


.post div





.post-footer .span




.post blockquote


.post blockquote p


.post img


.post .pic


#comments h4


#comments h4 strong


#comments-block


#comments-block dt


#comments-block dd



#comments-block dd p


.deleted-comment





#blog-pager


small

h1


h1 a


.description


h2


h2 a


h3


h3 a


acronym
a

.widecolumn .post




h2


h3


h3.comments


p img


img.centered
img.alignright
img.alignleft

.alignright


.alignleft


.title h1


.title h1 a


.title


.description


.kosong


    #siderbar ul


      #siderbar ul ol


  • #siderbar ul li


    #siderbar ul p



      #siderbar ul ul


      #siderbar ul ol


        #siderbar ul ul ul


    1. #siderbar ul ol li


  1. ol li

    • #siderbar ul ul li


    1. #siderbar ul ol li


.entry form



abbr
blockquote

blockquote cite

.center



hr

2009年6月4日 星期四

C/C++的const總介紹

const.c


簡單的介紹C中const的用法  1 int main()  2 {  3   const char ch = 'a';  4   const int a[5] = {1, 2, 3, 4, 5};    5   int b[5] = {6, 7, 8, 9, 10};    6   int c[4][4] = {{11,12,13,14},{15,16,17,18},{19,20,21,22},{23,24,25,26}};  7   const int *p1 = a;                8   int *const p2 = a;                9   const int * const p3 = b; 10   const int ** const p4 = c; 11 12   ch = 'b';//error: ch is const, can't be modified 13   p1 = &a[2]; //ok, *p1 is const, p1 is not 14   *p1 = 5;//error, *p1 is const, a[2] is const 15   *(p1 + 2) = 1; //error, *p1 is const 16   p1 = &b[2];//ok 17   *p1 = 4;//error, *p1 is const 18   p2 = &b[4];//error, p2 is const 19   p2++;//error, p2 is const 20   *p2 = 10;//error, *p2 is not const, p2 is, but a[0] is const 21   p2 = &a[5];//error, p2 is const 22   p3 = &b[1];//error, p3 is const 23   *p3 = 3;//error, *p3 is const 24   p4 = b;//error, p4 is const 25   *(*p4+2) = 10; //error, **p4 is const 26   *p4 = b; 27   printf("%d", **p4); //6, *p4 = b 28   **p4 = 10;//error, **p4 is const 29    30   return 0; 31 } 32 --------------------------------------------------------------------------------------

const.cpp


簡單的介紹C++中const的用法  1 /*  2  * =====================================================================================  3  *  4  *       Filename:  const.cpp  5  *  6  *    Description:    7  *  8  *        Version:  1.0  9  *        Created:  06/04/2009 09:01:15 PM 10  *       Revision:  none 11  *       Compiler:  gcc 12  * 13  *         Author:  YOUR NAME (), 14  *        Company:   15  * 16  * ===================================================================================== 17  */ 18 #include <stdio.h> 19 #include <stdlib.h> 20 class Ball { 21   static const int ID = 100;//initialize only once, can't modify anymore 22   //const int ID2; //can't modify it anymore, and initialize 23   char *name; 24   int money; 25   mutable int bonus; 26   public: 27   Ball(){ 28     name = (char *)malloc(8); 29     name[0] = 'y'; 30     name[1] = 's'; 31   } 32   int setID(int id){ 33     //ID = 200;//error, ID is const 34   } 35   void showID(){ 36     printf("ID:%d\n", ID); 37   } 38   const char* getConstName() { return name; } 39   char* getName() { return name; } 40   int getMoney() const { 41     //money++;//error, function is const, can't modify any its class member 42     bonus++;//ok, it is mutable, can be used in const function 43     return money+bonus; } 44 }; 45 int main() 46 { 47   Ball b = Ball(); 48   b.showID(); 49   printf("name:%s\n", b.getName()); 50   b.getName()[2]='l'; 51   printf("name:%s\n", b.getName()); 52   //b.getConstName()[2]='l';//error, return const can't modify 53   printf("money:%d\n", b.getMoney()); 54 55   return 0; 56 } 57 --------------------------------------------------------------------------------------

const.cpp


簡單的介紹C++中const templates的iterator用法,還有其中content為const時如何去掉const來呼叫  1 #include <iostream>  2 #include <vector>  3 #include <map>  4 #include <string>  5  6 using namespace std;  7  8 class Symbolic{  9     public: 10         Symbolic(int v, string e){ 11             value_ = v; 12             expr_ = e; 13         } 14 15         void Print(){ 16             cout<<"value:"<<value_<<", "<<expr_<<endl; 17         } 18          19         void constPrint() const{ 20             cout<<"value:"<<value_<<", "<<expr_<<endl; 21         } 22     private: 23         int value_; 24         string expr_; 25 }; 26 27 void vectorPrint(const vector<const Symbolic *>& v) 28 { 29     /* const_iterator for const template iteration */ 30     vector<const Symbolic *>::const_iterator v_iter; 31     for(v_iter = v.begin(); v_iter != v.end(); v_iter++){ 32         /* make const member to be normal */ 33         const_cast<Symbolic *>(*v_iter)->Print(); 34         /* const class pointer only can call const function */ 35         (*v_iter)->constPrint(); 36     } 37 38 } 39 40 void mapPrint(const map<int, char>& m) 41 { 42     /* const_iterator for const template iteration */ 43     map<int, char>::const_iterator m_iter; 44     for(m_iter = m.begin(); m_iter != m.end(); m_iter++){ 45         cout<<"index:"<<m_iter->first<<" -> "<<m_iter->second<<endl; 46     } 47 } 48 49 int main() 50 { 51     vector<Symbolic *> constraints; 52 53     constraints.push_back(new Symbolic(1, "x")); 54     constraints.push_back(new Symbolic(2, "y")); 55     constraints.push_back(new Symbolic(3, "z")); 56 57     /* make its member to be const access */ 58     vector<const Symbolic*> cs(constraints.begin(), 59                            constraints.end()); 60     /* print its value and make it const to be sure that we don't modify it */ 61     vectorPrint(cs); 62 63 64     map<int, char> symb; 65 66     symb[1] = 'a'; 67     symb[2] = 'b'; 68     symb[3] = 'c'; 69 70     mapPrint(symb); 71 72     return 0; 73 }