Home linux网络专题 Linux服务器 第 11 章 - 编辑器
第 11 章 - 编辑器

11.1 流行的编辑器

Linux下有众多运行于控制台环境的文本编辑器任你选用,它们包括:

  • vim: 强大而轻便的BSD传统编辑器。VI iMproved.

  • emacs: 重量级GNU传统编辑器。RMS (Richard M. Stallman)原创。

  • xemacs: Emacs的下一代,由Lucid原创。

  • mcedit: 新型GNU编辑器。也就是mc内置编辑器。参阅.

  • ae: 默认的小型编辑器(Potato)。通常不用它。

  • nano: 默认的小型GNU编辑器(Woody)。类似pico。

  • joe: 用于旧式的WordStar或TurboPascal。

  • jed: 快速、多功能、菜单式编辑器,兼容Emacs键盘操作方式。

  • jove: 微型编辑器,兼容Emacs键盘操作方式。

  • nvi: 新版vi。Bug-for-bug compatible with the original vi.

使用update-alternatives --config editor命令可设置默认的编辑器。许多程序也使用环境变量EDITORVISUAL来调用编辑器。参阅.

还有一些运行于X环境的编辑器也值得一提:

  • gvim: Vim with GUI (vim and vim-gtk package)

  • emacs: The One True Emacs (auto-detect X).

  • xemacs: Next generation Emacs (auto-detect X).

这些X客户端的命令使用标准选项如-fn a24,这对象我这样的老家伙来说就再好不过了:)参阅。

11.2 应急的编辑器

有些编辑器安装在/bin/下,这类编辑器至少应该安装一个,以免当/usr/不能访问时,无法编辑文件。

  • elvis-tiny: 最小的vi编辑器(用vi命令开打)

  • nano-tiny: 最小的非vi编辑器(用nano-tiny命令打开)

  • nano: 最小的非vi编辑器(用nano命令打开) (Sarge)

  • ed: 最小的编辑器(常驻系统但使用起来极不方便)

11.3 Emacs和Vim

11.3.1 Vim提示

程序运行时可按下<F1>;阅读“VIM - main help file”文档。

     <F1>;           帮助
     <esc>;          返回到正常模式
     V              Visual模式
     i              Insert模式
     :              命令行命令
     :set tw=72     设置文本宽为72
     <F11>;          Insert (paste) 模式
     :r! date -R    Insert RFC-822 数据
     qa             将键盘操作记录到注册表a
     q              停止键盘操作记录
     @a             播放注册表a中记录的键盘操作
     :edit foo.txt  载入并编辑另一个文件foo.txt
     :wnext         写入当前文件然后编辑下一个文件

q@可用来记录简单的键盘宏然后回放它们。例如,想创建一个宏为光标所在处的单词加上HTML斜体字标签,可以输入qii<i>;^[ea</i>;^[q(此处^[表示按ESC键)。然后,在单词前输入@i,编辑器就会自动为它加上<i>;和</i>;。

亦可参阅.

11.3.2 Emacs提示

     <F1>;                帮助
     <F10>;               菜单
     C-u M-! date -R     插入RFC-822数据

11.3.3 打开编辑器

     打开编辑器:                   emacs filename  vim filename
     以vi兼容方式打开:                             vim -C
     以vi不兼容方式打开:                           vim -N
     默认编译方式打开:             emacs -q        vim -N -u NONE

11.3.4 编辑器命令总汇(Emacs,Vim)

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

Tags: 11  编辑器  



Shares:Google书签Yahoo书签雅虎收藏夹365Key网摘新浪ViVi百度收藏天极网摘diglog和讯网摘POCO网摘YouNote网摘博拉网天下图摘 spurl blogmarksBlinkListredditdiggDel.icio.us

linux