Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15582
  • 博文数量: 7
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 85
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-04 23:49
文章分类

全部博文(7)

文章存档

2011年(1)

2008年(6)

我的朋友

分类: LINUX

2008-10-05 00:02:03

/*----------------------------------------------------------------------------------
Content:
    Startup and Exit:
    Move:
    Search:
    Delete:
    Add:
    Replace:
    Recover:
    Execute Command:
    Help:

version:   0.1              date:   20080911
----------------------------------------------------------------------------------*/
Vim is a powerful editor, i learn it by vimtutor yesterday, here is the note of it.


Startup and Exit:

0. To start Vim from the shell prompt type: vim FILENAME

1. To exit Vim type:        :q!   to trash all changes.
             OR type:         :wq   to save the changes.
NOTE: Pressing will place you in Normal mode or will cancel an unwanted and partially completed command.

Move:

0. The cursor is moved using either the arrow keys or the hjkl keys.
1. To repeat a motion prepend it with a number:   2w 3e
2. To move to the start of the line use a zero: 0
3. CTRL-G displays your location in the file and the file status.
             G              moves to the end of the file.
     number G          moves to that line number.
            gg              moves to the first line.
4. Typing % while the cursor is on a (,),[,],{, or } goes to its match.


Search:

0. Typing / followed by a phrase searches FORWARD for the phrase.
     Typing ? followed by a phrase searches BACKWARD for the phrase.
     After a search type n to find the next occurrence in the same direction or N to search in the opposite direction.
     CTRL-O takes you back to older positions, CTRL-I to newer positions.


Delete:

0. To delete the character at the cursor type: x
1. To delete from the cursor up to the next word type:    dw
2. To delete from the cursor to the end of a line type:    d$
3. To delete a whole line type:    dd
4. To delete from the cursor to the end of word type:      de (the same as dw)


Add:

0. To insert or append text type:
         i   type inserted text            insert before the cursor
         a type appended text          append after the cursor
         A   type appended text            append after the line
1. Type o to open a line BELOW the cursor and start Insert mode.
     Type O to open a line ABOVE the cursor.
2. The y operator yanks (copies) text, p puts (pastes) it.


Replace:
0. To replace the character under the cursor, type   r   and then the character you want to have there.
1. The change operator allows you to change from the cursor to where the motion takes you. ce   c$
2. The format for change is:
         c   [number]   motion
3. To substitute new for the first old in a line type    :s/old/new
     To substitute new for all 'old's on a line type       :s/old/new/g
     To substitute phrases between two line #'s type       :#,#s/old/new/g
     To substitute all occurrences in the file type        :%s/old/new/g
     To ask for confirmation each time add 'c'             :%s/old/new/gc
4. Typing a capital R enters Replace mode until is pressed.


Recover:

0. To undo previous actions, type:           u (lowercase u)
      To undo all the changes on a line, type: U (capital U)
      To undo the undo's, type:                 CTRL-R
1. To put back text that has just been deleted, type   p . This puts the deleted text AFTER the cursor

Execute Command:

0. :!command executes an external command.
1. :w FILENAME writes the current Vim file to disk with name FILENAME.
2. v motion :w FILENAME saves the Visually selected lines in file FILENAME.
3. :r FILENAME retrieves disk file FILENAME and puts it below the cursor position.
4. :r !dir reads the output of the dir command and puts it below the cursor position.
5. 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.

6. Prepend "no" to switch an option off:   :set noic

Help:
0. Type :help or press or to open a help window.
1. Type :help cmd to find help on cmd .
2. Type CTRL-W CTRL-W to jump to another window
3. Create a vimrc startup script to keep your preferred settings.
4. When typing a : command, press CTRL-D to see possible completions.
     Press to use one completion.
阅读(516) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Netbook蜂起-------趋势,各种型号

给主人留下些什么吧!~~