红联Linux门户
Linux帮助

vim系统学习六

发布时间:2008-11-16 12:59:41来源:红联作者:snowflytosky
Lesson 6.1: THE OPEN COMMAND

[attach]10456[/attach]
** Type o to open a line below the cursor and place you in Insert mode. **

1. Move the cursor to the line below marked --->.

2. Type the lowercase letter o to open up a line BELOW the cursor and place
you in Insert mode.

3. Now type some text and press to exit Insert mode.

---> After typing o the cursor is placed on the open line in Insert mode.

4. To open up a line ABOVE the cursor, simply type a capital O , rather
than a lowercase o. Try this on the line below.

---> Open up a line above this by typing O while the cursor is on this line.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.2: THE APPEND COMMAND


** Type a to insert text AFTER the cursor. **

1. Move the cursor to the start of the line below marked --->.

2. Press e until the cursor is on the end of li .

3. Type an a (lowercase) to append text AFTER the cursor.

4. Complete the word like the line below it. Press to exit Insert
mode.

5. Use e to move to the next incomplete word and repeat steps 3 and 4.

---> This li will allow you to pract appendi text to a line.
---> This line will allow you to practice appending text to a line.

Note: a, i and A all go to the same Insert mode, the only difference is where
the characters are inserted.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.3: ANOTHER WAY TO REPLACE


** Type a capital R to replace more than one character. **

1. Move the cursor to the first line below marked --->. Move the cursor to
the beginning of the first xxx .

2. Now press R and type the number below it in the second line, so that it
replaces the xxx .

3. Press to leave Replace mode. Notice that the rest of the line
remains unmodified.

5. Repeat the steps to replace the remaining xxx.

---> Adding 123 to xxx gives you xxx.
---> Adding 123 to 456 gives you 579.

NOTE: Replace mode is like Insert mode, but every typed character deletes an
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.4: COPY AND PASTE TEXT


** use the y operator to copy text and p to paste it **

1. Go to the line marked with ---> below and place the cursor after "a)".

2. Start Visual mode with v and move the cursor to just before "first".

3. Type y to yank (copy) the highlighted text.

4. Move the cursor to the end of the next line: j$

5. Type p to put (paste) the text. Then type: a second .

6. Use Visual mode to select " item.", yank it with y , move to the end of
the next line with j$ and put the text there with p .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.5: SET OPTION


** Set an option so a search or substitute ignores case **

1. Search for 'ignore' by entering: /ignore
Repeat several times by pressing n .

2. Set the 'ic' (Ignore case) option by entering: :set ic

3. Now search for 'ignore' again by pressing n
Notice that Ignore and IGNORE are now also found.

4. Set the 'hlsearch' and 'incsearch' options: :set hls is

5. Now type the search command again and see what happens: /ignore

6. To disable ignoring case enter: :set noic

Note: To remove the highlighting of matches enter: :nohlsearch

Note: If you want to ignore case for just one search command, use \c
in the phrase: /ignore\c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LESSON 6 SUMMARY

1. Type o to open a line BELOW the cursor and start Insert mode.
Type O to open a line ABOVE the cursor.

2. Type a to insert text AFTER the cursor.
Type A to insert text after the end of the line.

3. The e command moves to the end of a word.

4. The y operator yanks (copies) text, p puts (pastes) it.

5. Typing a capital R enters Replace mode until is pressed.

6. Typing ":set xxx" sets the option "xxx". Some options are:
'ic' 'ignorecase' ignore upper/lower case when searching
'is' 'incsearch' show partial matches for a search phrase
'hls' 'hlsearch' highlight all matching phrases
You can either use the long or the short option name.

7. Prepend "no" to switch an option off: :set noic
文章评论

共有 0 条评论