[ 上一頁 ] [ 目錄 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ 下一頁 ]
Linux 下有許多在控制台 (console) 環境下執行的文字編輯器任你選用,包括:
vim: 強大而輕便的 BSD 傳統編輯器。VI iMproved。
emacs: 重量級的 GNU 傳統編輯器。RMS (Richard M. Stallman) 原創。
xemacs: Emacs 的下一代,由 Lucid 原創。
mcedit: 初學者的 GNU 編輯器。也就是 mc
內建編輯器。參閱 MC 的編輯器, 第
4.2.5 節。
ae: 預設的小型編輯器 (Potato)。通常不用它。
nano: 預設的小型 GNU 編輯器 (Woody)。模彷 pico。
joe: 給舊式的 WordStar 或 TurboPascal 。
jed: 快速、多功能、選單式的編輯器,相容於 Emacs 的鍵盤操作方式。
jove: 微型編輯器,相容於 Emacs 的鍵盤操作方式。
nvi: 新版 vi。連 Bug 都相容於原本的 vi 。
使用 update-alternatives --config editor 命令可改變預設的編輯器。許多程式也使用環境變數 EDITOR 或 VISUAL 來決定編輯器。參閱 MC 的編輯器, 第 4.2.5 節 。
還有一些於 X 環境下執行的編輯器也值得一提:
gvim: Vim with GUI (vim 和 vim-gtk 套件)
emacs: 唯一的 Emacs (自動偵測 X) 。
xemacs: 次世代 Emacs (自動偵測 X) 。
這些 xclient 的命令列使用標準選項,如 -fn a24,這對像我這樣的老傢伙來說就再好不過了 :) 參閱 X clients, 第 9.4.4 節 。
有少數幾個編輯器安裝在 /bin 下。至少應該安裝一個這類的編輯器,以免
/usr/ 不能存取時,就無法編輯文件了。
elvis-tiny: 最小的 vi 編輯器 (用 vi 命令啟動)
nano: 最小的非 vi 編輯器 (用 nano-tiny 命令啟動)
ed: 最小的編輯器 (總是存在但使用起來不方便)
程式執行時可按下 <F1> 閱讀 "VIM - main help file" 文件。
<F1> 說明
<esc> 返回正常模式
V Visual 模式
i Insert 模式
: 命令列指令
:set tw=72 設定文字行寬為 72
<F11> 插入 (貼上) 模式
:r! date -R 插入 RFC-822 日期
qa 將鍵盤操作記錄到暫存器 a
q 停止鍵盤操作記錄
@a 執行暫存器 a 的鍵盤操作
:edit foo.txt 載入並編輯檔案 foo.txt
:wnext 寫入目前的檔案並編輯下一個檔案
q 和 @ 可用來記錄簡單的鍵盤巨集然後執行它們。例如,想建立一個巨集為將游標所在處的單詞加上 HTML 斜體字標籤,可以輸入 qii<i>^[ea</i>^[q (此處 ^[ 表示按 ESC 鍵) 。然後,在單詞前輸入 @i ,編輯器就會自動為它加上 <i> 和 </i> 。
也請參閱 在 Vim 中使用 GnuPG, 第 14.4.2 節 。
<F1> 說明
<F10> 選單
C-u M-! date -R 插入 RFC-822 日期
啟動編輯器: emacs filename vim filename
以與 vi 相容方式啟動: vim -C
以與 vi 不相容方式啟動: vim -N
以編譯預設值啟動: emacs -q vim -N -u NONE
exit: C-x C-c :qa /:wq /:xa /:q!
Get back/command mode: C-g <esc>
Backward(left): C-b h
Forward(right): C-f l
Next(down): C-n j
Previous(up): C-p k
stArt of line(^): C-a 0
End of line($): C-e $
mUltiple commands: C-u nnn cmd nnn cmd
Multiple commands: M-digitkey cmd
save File: C-x C-s :w file
beginning of buffer: M-< 1G
end of buffer: M-> G
scroll forward 1 screen: C-v ^F
scroll forward 1/2 screen: ^D
scroll forward 1 line: ^E
scroll backward 1 screen: M-v ^B
scroll backward 1/2 screen: ^U
scroll backward 1 line: ^Y
scroll the other window: M-C-v
delete under cursor: C-d x
delete from cursor to eol: C-k D
iSearch forward: C-s
isearch Reverse: C-r
Search forward: C-s enter /
search Reverse: C-r enter ?
isearch regexp: M-C-s
isearch backward regexp: M-C-r
search regexp: M-C-s enter /
search backward regexp: M-C-r enter ?
Help: C-h C-h :help
Help Apropos: C-h a
Help key Bindings: C-h b :help [key]
Help Info: C-h i
Help Major mode: C-h m
Help tutorial: C-h t :help howto
Undo: C-_ u
Redo: C-f ^R
Mark cursor position: C-@ m{a-zA-Z}
eXchange Mark and position: C-x C-x
goto mark in current file: '{a-z}
goto mark in any file: '{A-Z}
copy region: M-w {visual}y
kill region: C-w {visual}d
Yank and keep buffer: C-y
Yank from kill buffer: M-y p
convert region to Upper: C-x C-u {visual}U
convert region to Lower: C-x C-l {visual}u
Insert special char: C-q octalnum/keystroke
^V decimal/keystroke
replace: M-x replace-string :%s/aaa/bbb/g
replace regexp: M-x replace-regexp :%s/aaa/bbb/g
query replace: M-% :%s/aaa/bbb/gc
query replace: M-x query-replace
query replace regexp: M-x query-replace-regexp
Open file: C-x C-f :r file
Save file: C-x C-s :w
Save all buffers: C-x s :wa
Save as: C-x C-w file :w file
Prompt for buffer: C-x b
List buffers: C-x C-b :buffers
Toggle read-only: C-x C-q :set ro
Prompt and kill buffer: C-x k
Split vertical: C-x 2 :split
Split horizontal: C-x 3 :vsplit (ver. 6)
Move to other window: C-x o ^Wp
Delete this window: C-x 0 :q
Delete other window(s): C-x 1 ^Wo
run shell in bg: M-x compile
kill shell run in bg: M-x kill-compilation
run make: :make Makefile
check error message: C-x` :echo errmsg
run shell and record: M-x shell :!script -a tmp
...clean BS, ... :!col -b <tmp >record
...save/recall shell record: C-x C-w record :r record
run shell: M-! sh :sh
run command: M-! cmd :!cmd
run command and insert: C-u M-! cmd :r!cmd
run filter: M-| file {visual}:w file
run filter and insert: C-u M-| filter {visual}:!filter
show option :se[t] {option}?
reset option to default :se[t] {option}&
reset boolean option :se[t] no{option}
toggle boolean option :se[t] inv{option}
wrap text at column 72 :se tw=72
do not wrap :se tw=0
autoindent :se ai
expand tab :se et
specify comment (mail) :se comments=n:>,n:\|
run GDB M-x gdb
describe GDB mode C-h m
step one line M-s
next line M-n
step one instruction (stepi) M-i
finish current stack frame C-c C-f
continue M-c
up arg frames M-u
down arg frames M-d
copy number from point, insert at the end
C-x &
set break point C-x SPC
要使用 Vim 所有的功能和高亮度關鍵字,請在 ~/.vimrc 或
/etc/vimrc 加入下列內容:
set nocompatible
set nopaste
set pastetoggle=<f11>
syn on
Paste 模式能避免自動縮進功能影響在控制台終端下的剪下-貼上操作,比只用 ":set noai" 更好。
有關 GnuPG 整合的資訊,請參閱 在 Vim 中使用 GnuPG, 第 14.4.2 節 。
執行 apt-get install exuberant-ctags,接著就可以在源碼檔中使用 ctags 了。在 Vim 中輸入 :tag function_name 可直接跳到 function_name 的開始行。它適用於 C 、 C++ 、 Java 、 Python 和許多其它的語言。
Emacs 也有相同的 ctags 功能。
在 Vim 命令模式下輸入 so \$VIMRUNTIME/syntax/2html.vim ,可將螢幕上高亮度顯示的文字轉化為 HTML 文字,然後用 :w file.html 存檔, :q 退出。對 C 等源碼特別適用。
vim 分割螢幕
vim 可以在多重分割視窗 (multi-split-screen)
環境下編輯多個檔案。想了解有關詳情,可輸入 :help usr_08.txt 。
要分割螢幕顯示多個不同文件,請在 vi 命令提示後輸入:
:split another-file
:vsplit another-file
或在 shell 提示時:
$ vi -o file1.txt file2.txt # 水平分割
$ vi -O file1.txt file2.txt # 垂直分割
就可以使用多視窗 vi。
$ vimdiff file.txt~ file.txt # 檢查 file.txt 的最近修改情況
$ vimdiff file.en.sgml file.fr.sgml # 檢查翻譯的變化
$ gvimdiff file.txt~ file.txt # 在 X 中
上述操作可以明確地顯示原始文件與備份文件的差別。對 SGML 文件,它進行標籤匹配檢查,所以用它來檢查翻譯結果十分有效。
用 CTRL-W 命令指定游標移動:
Ctrl-W + 增加視窗大小
Ctrl-W - 減小視窗大小
Ctrl-W h 移動至視窗左邊
Ctrl-W j 移動至視窗下方
Ctrl-W k 移動至視窗上方
Ctrl-W l 移動至視窗右邊
...
下列命令用於控制螢幕捲軸:
:set scrollbind
:set noscrollbind
[ 上一頁 ] [ 目錄 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ 下一頁 ]
Debian 參考手冊
CVS, 週四 一月 18 11:53:38 UTC 2007osamu#at#debian.orgasho#at#debian.org.tw