Linux editor

xiaoxiao2021-03-06  44

Excerpt from:

http://blog.9cbs.net/onefish/archive/2005/01/04/239558.aspx

============================================================================================================================================================================================================= ======

11.1 Popular editor

LINUX has a number of text editors running in the console environment, they include:

Vim: Powerful and lightweight BSD traditional editor. VI Imacket: Heavyweight GNU Traditional Editor. RMS (Richard M. Stallman) Original. Xemacs: The next generation of Emacs is originally created by Lucid. MCEDIT: New GNU Editor. That is, the MC built-in editor. Refer to the editor, section 4.3.5. Ae: The default small editor (Potato). Never use it. NANO: Default Small GNU Editor (Woody). Similar to Pico. Joe: Used for old WordStar or TurboPascal. JED: Quick, multi-function, menu editor, compatible EMACS keyboard operation mode. JOVE: Micro Editor, compatible with EMACS keyboard operation. NVI: New VI. Bug-for-bug compatible with the Original VI.

Use the update-alternatives --config editor command to set the default editor. Many programs also use environment variables Editor or Visual to call the editor. Refer to the editor, section 4.3.5.

There are also some editors running on the X environment.

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 X clients command use standard options such as -fn A24, this object I have such a good guy. It is better :) See the X client, section 9.4.4.

11.2 Emergency Editor

Some editors are installed under / bin, such editors should be installed at least one to avoid editing files when / usr cannot access.

Elvis-Tiny: Minimal VI Editor (play with VI command) Nano-Tiny: Minimum non-VI editor (open with nano-tiny command) ED: Minimum editor (extremely inconvenient to use it)

11.3 Emacs and Vim

11.3.1 VIM prompt

The "Vim - Main Help File" document can be read when the program is running.

Help

Returns to normal mode

V Visual mode

i INSERT mode

: Command line command

: SET TW = 72 Set text width 72

Insert (Paste) mode

: r! Date -r INSERT RFC-822 Data

QA records the keyboard to register a

q Stop keyboard operation record

@A Play the keyboard operation recorded in the registry A: edit foo.txt load and edit another file foo.txt

: wnext writes the current file and edit the next file

Q and @ can be used to record simple keyboard macros and then play back them. For example, if you want to create a word that macro is located at the cursor, you can enter the HTML oblique word tag, you can enter QII ^ [EA ^ [q (here ^ [means pressing the ESC button). Then, enter @i before the word, the editor will automatically add and .

It can also be found in VIM using GNUPG, section 14.4.2.

11.3.2 Emacs Tips

Help

menu

C-U m-! Date -r inserts RFC-822 data

11.3.3 Open the editor

Open Editor: Emacs FileName Vim FileName

Open in VI compatibility: vim -c

Open in VI is not compatible: vim -n

Default compilation mode Open: Emacs -q Vim -n -u None

11.3.4 Editor Commands (Emacs, Vim)

EXIT: C-X C-C: QA /: WQ /: XA /: Q!

Get Back / Command Mode: C-G

Backward: C-B h

Forward (Right): C-F L

Next (down): C-N J

Previous: C-Pk

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-VDELETE 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-ReplaceQuery 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: 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 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

11.3.5 VIM settings

To use the full features and keywords of Vim, add the following: Add:

Set Nocompatible

Set nopaste

Set Pastetoggle =

SYN ON

Paste mode can avoid automatic indentation functional impact on the shear under the console terminal - paste operation, it is more like ": set noai".

Information about GNUPG integration is used in VIM using GNUPG, section 14.4.2.

11.3.6 CTAGS

Execute the APT-GET Install Exuberant-CTags, then you can run CTAGS in the source code file. Enter: tag function_name can jump directly to the beginning of function_name. It applies to C, C , Java, Python, and many other editing languages.

Emacs has the same CTAGS function.

11.3.7 Transforming highlight screens to HTML files

Enter SO /$VIMRUNTIME/SYNTAX/2HTML.vim in VIM command mode to convert the text on the screen to HTML code, then: w File.html,: q Exit. Special applicable to Class C is particularly applicable.

11.3.8 Separation screen with VIM

VIM can edit multiple files in a multi-split-screen environment. Want to know more about details: Help usr_08.txt.

To split the screen to display multiple different files, enter after the VI command prompt:

: split another-file

: vsplit another-file

Or after the shell prompt:

$ vi -o file1.txt file2.txt # horizontal segmentation

$ vi-file1.txt file2.txt # vertical segmentation

You can open the multi-window VI.

$ vimdiff file.txt ~ file.txt # Check the most recent modification of File.txt

$ VIMDIFF file.en.sgml file.fr.sgml # Check translation

$ gvimdiff file.txt ~ file.txt # under x

The above operations can explicitly display the difference between source files and backup files. For the SGML file, it performs label matching check, so use it to check the translation results very effective.

Specify the cursor movement with the CTRL-W command:

Ctrl-w enlargement window

Ctrl-W - Reduce Window

Ctrl-w h moves to the left side of the window

Ctrl-w j moves to the window

Ctrl-w k moves to the window

Ctrl-w l moves to the right of the window

...

The following command is used to scroll control:

: Set Scrollbind

: set NoscrollBind

转载请注明原文地址:https://www.9cbs.com/read-45268.html

New Post(0)