[ назад ] [ Содержание ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ вперед ]
Linux offers many alternatives for console text editors. Among them:
vim
: Powerful and light BSD-heritage editor. VI iMproved.
emacs
: Ultimate and heavy GNU-heritage editor. RMS (Richard M.
Stallman) original.
xemacs
: Emacs: The Next Generation, originally from Lucid.
mcedit
: Newbie GNU editor. Identical to mc
internal
editor. See Редактор в MC, раздел
4.2.5.
ae
: Default small editor (Potato). Avoid this.
nano
: Default small GNU editor (Woody). Emulates
pico
.
joe
: For WordStar or TurboPascal old-timers.
jed
: Fast, full-featured menu-driven editor with Emacs key
bindings.
jove
: Very small editor with Emacs key bindings.
nvi
: New vi. Bug-for-bug compatible with the original vi.
Use update-alternatives --config editor to change the default editor. Also, many programs use environment variables EDITOR or VISUAL to decide which editor to use. See Редактор в MC, раздел 4.2.5.
Also a few X-based text editors are noteworthy:
gvim
: Vim with GUI (vim
and vim-gtk
package)
emacs
: The One True Emacs (auto-detect X).
xemacs
: Next generation Emacs (auto-detect X).
These xclient commands take standard options such as -fn a24, which makes life easy for older folks like me :) See X clients, раздел 9.4.4.
There are a few editors which reside in /bin
. One of these should
be installed to ease editing files when /usr
is not accessible.
elvis-tiny
: Minimum vi editor (vi
to start)
nano-tiny
: Minimum non-vi editor (nano-tiny
to start)
ed
: Minimum editor (always there but tough to use)
Read the "VIM - main help file" document by pressing <F1> while running the program.
<F1> Help <esc> Back to normal mode V Visual mode i Insert mode : Command-line commands :set tw=72 Set text width to 72 <F11> Insert (paste) mode :r! date -R Insert RFC-822 date qa Record keystrokes into register a q Stop keystroke recording @a Execute keystrokes from register a :edit foo.txt Edit another file by loading foo.txt :wnext Write current file and edit next file
q and @ can be used for simple macro recording and playback. For instance, to create a macro that inserts HTML italics tags around the word at the cursor, you could enter qii<i>^[ea</i>^[q (where ^[ is the ESC key). Then typing @i at the start of a word would add the tags <i> and </i>.
See also Using GnuPG with Vim, раздел 14.4.2.
<F1> Help <F10> Menu C-u M-! date -R Insert RFC-822 date
start editor: emacs filename vim filename start in vi compatible: vim -C start in vi non-compatible: vim -N start with compile default: 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
In order to use all Vim features and syntax highlighting, include the following
lines in ~/.vimrc
or /etc/vimrc
:
set nocompatible set nopaste set pastetoggle=<f11> syn on
Paste mode enables one to avoid autoindent interfering with cut-and-paste operations on a console terminal. It does more than just a simple ":set noai".
See Using GnuPG with Vim, раздел 14.4.2 for GnuPG integration.
apt-get install exuberant-ctags and run ctags
on the
source files. Type :tag function_name in Vim to jump
to the line where function_name starts. The tags work for C, C++,
Java, Python, and many other languages.
Emacs has the same ctags capabilities.
so \$VIMRUNTIME/syntax/2html.vim from Vim command mode will convert highlighted text to HTML text. Save with :w file.html and :q. Useful for C code, etc.
vim
vim
can edit multiple files in a multi-split-screen environment.
Type :help usr_08.txt for details.
To split the screen display between different files, type at the vi command prompt:
:split another-file :vsplit another-file
Or at a shell prompt:
$ vi -o file1.txt file2.txt # Horizontal split $ vi -O file1.txt file2.txt # Vertical split
will provide multiwindow vi.
$ vimdiff file.txt~ file.txt # check recent changes of file.txt $ vimdiff file.en.sgml file.fr.sgml # check changes of translation $ gvimdiff file.txt~ file.txt # in X
will provide a nice view of differences between an original and a backup file. In SGML it matches tags, so comparing translations in this mode works very well.
Special cursor movements with Ctrl-W commands:
Ctrl-W + increase the size of a window Ctrl-W - decrease the size of a window Ctrl-W h move to the window left Ctrl-W j move to the window below Ctrl-W k move to the window above Ctrl-W l move to the window right ...
Use the following to control screen scrolling:
:set scrollbind :set noscrollbind
[ назад ] [ Содержание ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ вперед ]
Справочник по Debian
CVS, Чтв 18. Янв 2007, 11:54:11 UTCosamu#at#debian.org
qref#at#yandex.ru