Gedit and VI use __linux under Linux

Source: Internet
Author: User

1. Gedit

1, start:
Starting from a menu: application--> attachment--> Text Editor
Execute the following command from the command line: gedit
2, Window Description:
Menu bar: Contains all the commands you need to work with files in Gedit.
Toolbars: Contains a subset of commands that you can access from the menu bar.
Display area: This area contains the text of the file you are editing.
Output window: Displays the output returned by the Shell command plug-in and the diff file plug-in.
Status bar: Displays information about the current gedit activity and contextual information about the menu item.
3, small tips:
A, open multiple files:
To open multiple files from the command line, type the following command, and then press ENTER: Gedit file1.txt file2.txt file3.txt
B. Deliver the command output to a file:
For example, to deliver the output of the LS command to a text file, type ls | Gedit, and then press ENTER. The output of the LS command is displayed in a new file in the Gedit window.
C, change the highlighting mode for file preparation:
View--> highlighting Mode--> Markup Language-->html You can view HTML files in color mode
D, the use of Plug-ins:
Document Statistics: Calculates the number of lines in the current file, the number of words, the number of characters, and the number of bytes. The plug-in displays the results in a Document Statistics dialog box.
Indent: Indents selected rows or removes indents from selected rows.
Insert Date/Time: Inserts the current date and time in the file.
Shell: command displays the text output of the shell command in the Output window.
Sort: Sorts the selected text.
E, shortcut keys:
Ctrl-z: Undo
Ctrl-c: Copying
Ctrl-v: Paste
CTRL-T: Indent
Ctrl-q: Exit
Ctrl-s: Saving
Ctrl-r: Replacing
Ctrl+tab switch
Ctrl+w off tabs

2 Vi

The VI Editor is the standard editor for all UNIX and Linux systems, and it's powerful for any latest text
Editor, here is a brief introduction to its usage and a small number of instructions. Because of the UNIX and Linux system
What version of the VI editor is exactly the same, so you can learn more about it in any other place that introduces VI. Vi
Linux is also the most basic text editor, learn it, you will be in the Linux world unimpeded.
1, VI of the basic concept
Basically VI can be divided into three states, namely, command mode, the insertion mode (insert
mode) and the bottom line pattern (last lines mode), the functions of each pattern are distinguished as follows:

(1) Command mode.

Controls the movement of the screen cursor, the deletion of characters, words, or rows, the movement of a section, and the entry mode,
Or to last line mode.

2 Insert Mode

Only in insert mode, you can do text input, press the "esc" key to return to the command line mode.

3 End Line Mode

To save or exit VI, you can also set up an editing environment, such as finding a string, listing line numbers ... Wait

But generally we use the VI to simplify to two modes, that is, the bottom line mode is also included in the
command-line pattern command mode.

2, VI of the basic operation
a) into VI

After the system prompts the symbol to enter VI and the file name, enters the vi full screen editing picture:

$ VI myfile


But one thing to be particularly aware of is that after you enter VI, you are in command mode.
, you can enter text by switching to insert mode. First Use VI people will want to first
With the next key to move the cursor, the result of the computer has been beep beep, to their own gas a half to death, so into the VI, first do not
Move on, switch to insert mode.

b switch to insert mode edit file

Under Command mode, click the letter "i" to enter the Insert mode (Ins
ert mode) ", this time you can begin to enter text.

c) the toggle of Insert

You are currently in insert mode, you can only enter text all the time if you find the error
The word. Want to use the cursor keys to move back, the word deleted, you need to first click the "esc" key to go to the command line mode (c
Ommand mode) "and then delete the text.

d) Exit VI and save documents

Under Command mode, click the ":" colon key to enter "last line mode
", for example:

: w filename (enter "w filename" to save the article with the specified filename filename)

: Wq (input "wq", save and Exit VI)

: q! (Input q!, do not save forced exit VI)


3, command-line mode (Command mode) function key
1). Insert mode

Press "i" to switch into insert mode "insert mode", press "I" to enter insert mode after the cursor current bit
Start input file;

When you press "a" into insert mode, enter the text from the next position in the current cursor position.

When you press "o" into insert mode, you insert a new row and enter text from the beginning of the line.

2). Switch from insert mode to command line mode

Press the "esc" key.

3). Move cursor

VI can be directly on the keyboard to move around the cursor up and down, but the normal VI is in lowercase English letter "h", "
j","k","l", respectively, control the cursor left, down, up, right one grid.

Press "ctrl"+"b": The screen moves one page to the back.

Press "ctrl"+"f": The screen moves one page to the front.

Press "ctrl"+"u": The screen moves half a page to the back.

Press "ctrl"+"d": The screen moves half a page to the front.

"0" by number: Moves to the beginning of the article.

Press "g": Move to the end of the article.

Press "$": Moves to the end of the line where the cursor is located.

Press "^": Move to the beginning of the line where the cursor is positioned

Press "w": The cursor jumps to the beginning of the next word

Press "e": The cursor jumps to the end of the next word

Press "b": Cursor back to the beginning of the last word

Press "#l": the cursor moves to the position of the line, such as: 5l,56l.

4). Delete text

"x": Every time you click, delete the "back" character at the cursor position.

"#x": for example, "6x" represents the "back" 6 characters at the location where the cursor is deleted.

"x": Uppercase X, each time, deletes the "before" character in the position of the cursor.

"#X": for example, "20x" represents the "front" 20 characters where the cursor is deleted.

"dd": Deletes the line where the cursor is located.

' #dd ': Delete # line starting at the line where the cursor is located

5). Copy

"yw": Copies the character of the cursor at the end of the word to the buffer.

' #yw ': Copy # Word to Buffer

"yy": The row to the buffer where the cursor is copied.

#yy: For example, "6yy" indicates that the copy is "down" 6 lines of text from the line where the cursor is located.

"p": Pastes the characters in the buffer into the position of the cursor. Note: All copy commands related to "Y" are
You must work with "P" to complete the copy and paste function.

6). Replace

"r": Replaces the character at which the cursor is located.

"r": Replaces the character where the cursor is, until the "esc" key is pressed.

7). Reply Last Action

"u": If you execute a command incorrectly, you can press "u" immediately and go back to the previous operation. Press "U" multiple times
You can perform multiple replies.

8). Change

"cw": Change the word at the end of the cursor

"c#w": For example, "c3w" represents a change of 3 words

9). Skip to the specified line

"ctrl"+"g" lists the line number of the row where the cursor is located.

"#G": "15g", for example, represents moving the cursor to the beginning of the 15th line of the article.

4, last line mode under the command introduction
Before using "last line mode", remember to press the "esc" key to determine that you are already in "command m
After ode", then press":"Colon to enter"last line mode".

A) List line numbers

"set nu": After entering "set nu", the line number is listed before each line in the file.

B jump to a row in the file

The "#":"#" number denotes a number, enters a number after the colon, and then presses the ENTER key to jump to the line.
If you enter the number 15, and then return, you will jump to the 15th line of the article.

C) Find characters

"/keyword": Press the "/" key first, then enter the character you want to look for, if the keyword you are looking for the first time is not what you want
, you can always press "n" to find the keyword you want.

"? keywords": Press "?" first Key, and then enter the character you want to find if the keyword you are looking for is not what you want
If you want, you can always press "n" to look forward to the keyword you want.

D) Save the file

"w": You can save the file by typing the letter "w" the colon.

E) Leaving VI

"q": Press "q" is exit, if unable to leave VI, can be in "q" heel a "!" Forced to leave VI.


"qw": Generally recommended to leave, with "w" to use together, so that when the exit can also save the file.


5, vi command list
1. The following table lists the functions of some keys in command mode:

H
Move left cursor one character

L
Move the cursor one character to the right

K
Move the cursor up one line

J
Move the cursor down one line

^
The cursor moves to the beginning of the line

0
Number "0", the cursor moves to the beginning of the article

G
The cursor moves to the end of the article

$
The cursor moves to the end of the line

Ctrl+f
Turn the screen forward

Ctrl+b
Turn the screen back

Ctrl+d
Turn the half screen forward

Ctrl+u
Turn Back half screen

I
Inserts a character before the cursor position

A
The last character at the cursor position starts to increase

O
Inserts a new row, starting at the beginning of the line

Esc
Retreat from input status to command state

X
Remove the character following the cursor

#x
Delete # characters after the cursor

X
(capital X), delete the characters before the cursor

#X
Delete the # characters in front of the cursor

Dd
Delete the line where the cursor is located

#dd
Deletes the # line from the number of rows from the cursor

yw
Copy a word in the position of the cursor

#yw
Copy the # Word at the location of the cursor

Yy
Copy a row in the position of the cursor

#yy
Copy the # line from the number of rows from the cursor

P
Paste

U
Cancel operation

cw
Change a word in the position of the cursor

#cw
Change the # Word at the cursor location


2. The following table lists some instructions in line command mode
W filename
Save the file being edited as filename

WQ filename
Save the file being edited as filename and exit VI

Q!
Discard all modifications and exit VI

Set Nu
Show line Numbers

Or?
Find, enter what you want to find in/after

N
Use with/or? If the lookup is not a keyword you are looking for, press N or backwards (with/in conjunction) or forward (
Continue searching until you find it.


For the first time with VI, there are a few caveats to remind:
1, with vi open the file, is in the "command mode", you want to switch to the insert mode (
Insert mode) "To be able to enter text. Toggle method: Under Command-Line mode (Command mode), press a
The next letter "i" into insert mode, which allows you to start typing.

2, after editing, you need to switch from the Insert mode to command line mode to save the file, switching methods: Press "esc
Key
3, save and exit the file: In the command mode input: Wq can. (Don't forget the front of the Wq:)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.