4Debian.Info - Портал русскогоязычного сообщества Debian Карта сайта Контакты

Меню

Репозитории Debian

Скачать Debian

Установка Debian - Видео



Авторизация:

Новые статьи

Статьи в RSS

Новые комментарии

Новые уроки

Уроки в RSS


[ назад ] [ Содержание ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ A ] [ вперед ]

Справочник по Debian
Глава 11 - Editors

11.1 Popular editors

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 (Ri/hdbk/ard 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 /hdbk/ange the default editor. Also, many programs use environment variables EDITOR or VISUAL to decide whi/hdbk/ 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 e Emacs (auto-detect X).

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

These xclient commands take standard options su/hdbk/ as -fn a24, whi/hdbk/ makes life easy for older folks like me :) See X clients, раздел 9.4.4.

11.2 Rescue editors

There are a few editors whi/hdbk/ 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)

11.3 Emacs and Vim

11.3.1 Vim hints

Read the "VIM - main help file" document by pressing <F1> while running the program.

Bash:
  1. <F1> Help
  2. <esc> Back to normal mode
  3. V Visual mode
  4. i Insert mode
  5. : Command-line commands
  6. :set tw=72 Set text width to 72
  7. <F11> Insert (paste) mode
  8. :r! date -R Insert RFC-822 date
  9. qa Record keystrokes into register a
  10. q Stop keystroke recording
  11. @a Execute keystrokes from register a
  12. :edit foo.txt Edit another file by loading foo.txt
  13. :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.

11.3.2 Emacs hints

Bash:
  1. <F1> Help
  2. <F10> Menu
  3. C-u M-! date -R Insert RFC-822 date

11.3.3 Starting the editor

Bash:
  1. start editor: emacs filename vim filename
  2. start in vi compatible: vim -C
  3. start in vi non-compatible: vim -N
  4. start with compile default: emacs -q vim -N -u NONE

11.3.4 Editor command summary (Emacs, Vim)

Bash:
  1. exit: C-x C-c :qa /:wq /:xa /:q!
  2. Get back/command mode: C-g <esc>
  3. Backward(left): C-b h
  4. Forward(right): C-f l
  5. Next(down): C-n j
  6. Previous(up): C-p k
  7. stArt of line(^): C-a 0
  8. End of line($): C-e $
  9. mUltiple commands: C-u nnn cmd nnn cmd
  10. Multiple commands: M-digitkey cmd
  11. save File: C-x C-s :w file
  12. beginning of buffer: M-< 1G
  13. end of buffer: M-> G
  14. scroll forward 1 screen: C-v ^F
  15. scroll forward 1/2 screen: ^D
  16. scroll forward 1 line: ^E
  17. scroll backward 1 screen: M-v ^B
  18. scroll backward 1/2 screen: ^U
  19. scroll backward 1 line: ^Y
  20. scroll the other window: M-C-v
  21. delete under cursor: C-d x
  22. delete from cursor to eol: C-k D
  23. iSear/hdbk/ forward: C-s
  24. isear/hdbk/ Reverse: C-r
  25. Sear/hdbk/ forward: C-s enter /
  26. sear/hdbk/ Reverse: C-r enter ?
  27. isear/hdbk/ regexp: M-C-s
  28. isear/hdbk/ backward regexp: M-C-r
  29. sear/hdbk/ regexp: M-C-s enter /
  30. sear/hdbk/ backward regexp: M-C-r enter ?
  31. Help: C-h C-h :help
  32. Help Apropos: C-h a
  33. Help key Bindings: C-h b :help [key]
  34. Help Info: C-h i
  35. Help Major mode: C-h m
  36. Help tutorial: C-h t :help howto
  37. Undo: C-_ u
  38. Redo: C-f ^R
  39. Mark cursor position: C-@ m{a-zA-Z}
  40. eX/hdbk/ange Mark and position: C-x C-x
  41. goto mark in current file: '{a-z}
  42. goto mark in any file: '{A-Z}
  43. copy region: M-w {visual}y
  44. kill region: C-w {visual}d
  45. Yank and keep buffer: C-y
  46. Yank from kill buffer: M-y p
  47. convert region to Upper: C-x C-u {visual}U
  48. convert region to Lower: C-x C-l {visual}u
  49. Insert special /hdbk/ar: C-q octalnum/keystroke
  50. ^V decimal/keystroke
  51. replace: M-x replace-string :%s/aaa/bbb/g
  52. replace regexp: M-x replace-regexp :%s/aaa/bbb/g
  53. query replace: M-% :%s/aaa/bbb/gc
  54. query replace: M-x query-replace
  55. query replace regexp: M-x query-replace-regexp
  56. Open file: C-x C-f :r file
  57. Save file: C-x C-s :w
  58. Save all buffers: C-x s :wa
  59. Save as: C-x C-w file :w file
  60. Prompt for buffer: C-x b
  61. List buffers: C-x C-b :buffers
  62. Toggle read-only: C-x C-q :set ro
  63. Prompt and kill buffer: C-x k
  64. Split vertical: C-x 2 :split
  65. Split horizontal: C-x 3 :vsplit (ver. 6)
  66. Move to other window: C-x o ^Wp
  67. Delete this window: C-x 0 :q
  68. Delete other window(s): C-x 1 ^Wo
  69. n shell in bg: M-x compile
  70. kill shelln in bg: M-x kill-compilation
  71. n make: :make Makefile
  72. /hdbk/eck error message: C-x` :e/hdbk/o errmsg
  73. n shell and record: M-x shell :!script -a tmp
  74. ...clean BS, ... :!col -b <tmp >record
  75. ...save/recall shell record: C-x C-w record :r record
  76. n shell: M-! sh :sh
  77. n command: M-! cmd :!cmd
  78. n command and insert: C-u M-! cmd :r!cmd
  79. n filter: M-| file {visual}:w file
  80. n filter and insert: C-u M-| filter {visual}:!filter
  81. show option :se[t] {option}?
  82. reset option to default :se[t] {option}&
  83. reset boolean option :se[t] no{option}
  84. toggle boolean option :se[t] inv{option}
  85. wrap text at column 72 :se tw=72
  86. do not wrap :se tw=0
  87. autoindent :se ai
  88. expand tab :se et
  89. specify comment (mail) :se comments=n:>,n:\|
  90.  
  91. n GDB M-x gdb
  92. describe GDB mode C-h m
  93. step one line M-s
  94. next line M-n
  95. step one insction (stepi) M-i
  96. finish current stack frame C-c C-f
  97. continue M-c
  98. up arg frames M-u
  99. down arg frames M-d
  100. copy number from point, insert at the end
  101. C-x &
  102. set break point C-x SPC

11.3.5 Vim configuration

In order to use all Vim features and syntax highlighting, include the following lines in ~/.vimrc or /etc/vimrc:

Bash:
  1. set nocompatible
  2. set nopaste
  3. set pastetoggle=<f11>
  4. 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.

11.3.6 Ctags

apt-get install exuberant-ctags andn 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.

11.3.7 Convert a syntax-highlighted screen to HTML source

so \$VINTIME/syntax/2html.vim from Vim command mode will convert highlighted text to HTML text. Save with :w file/ and :q. Useful for C code, etc.

11.3.8 Split screen with 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:

Bash:
  1. :split another-file
  2. :vsplit another-file

Or at a shell prompt:

Bash:
  1. $ vi -o file1.txt file2.txt # Horizontal split
  2. $ vi -O file1.txt file2.txt # Vertical split

will provide multiwindow vi.

Bash:
  1. $ vimdiff file.txt~ file.txt # /hdbk/eck recent /hdbk/anges of file.txt
  2. $ vimdiff file.en.sgml file.fr.sgml # /hdbk/eck /hdbk/anges of translation
  3. $ gvimdiff file.txt~ file.txt # in X

will provide a nice view of differences between an original and a backup file. In SGML it mat/hdbk/es tags, so comparing translations in this mode works very well.

Special cursor movements with Ctrl-W commands:

Bash:
  1. Ctrl-W + increase the size of a window
  2. Ctrl-W - decrease the size of a window
  3. Ctrl-W h move to the window left
  4. Ctrl-W j move to the window below
  5. Ctrl-W k move to the window above
  6. Ctrl-W l move to the window right
  7. ...

Use the following to control screen scrolling:

Bash:
  1. :set scrollbind
  2. :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 UTC

Osamu Aoki osamu#at#debian.org
Перевод Ильи В. Головко qref#at#yandex
Authors, раздел A.1



Яндекс.Метрика
4Debian.Info
При полной или частичной перепечатке текстов статей и публикаций гиперссылка на www.4debian.info обязательна. | "4Debian.Info" | © 2017