vimtutor总结

来源:互联网 发布:数据信息加工 编辑:程序博客网 时间:2024/06/05 14:20

Lesson 1

1.使用arrow 键或者hjkl使光边移动

      h (left)       j (down)       k (up)       l (right)

2.从shell提示符启动vim

     vim FILENAME <ENTER>

3.退出vim

<ESC>   :q!   <ENTER>    丢弃所有变化。
  <ESC>   :wq   <ENTER>  保存所有的变化。

4.删除光标处的字符 

x

5.插入或者附加文字

i   type inserted text   <ESC> 光标前插入

A   type appended text   <ESC>         行末附加

Lesson 2

1.删除光标到下一个单词

dw

2.删除光标到行末

d$

3.删除整行

dd
4.motion前加一个数字来重复该动作

2w

5.改变文本的命令格式

operator   [number]   motion
  其中:
       operator - is what to do, such as  d  for delete
       [number] - is an optional count to repeat the motion
       motion   - moves over the text to operate on, such as  w (word),
                  $ (to the end of line), etc.
6.光标移动到行首用zero

0
7. 撤销之前的actions

u(小写的u)
  撤销本行的所有变化

U(大写)

  重置已撤销的部分

 CTRL-R

Lesson 3

1.写回已经删除的文字,p。这些文字将会放在光标之后

2.替换光标处的文字 r

3.change operator可以改变从光标处到你需要的motion处

ce 改变光标到单词尾部的字符
c$改变光标到行尾的字符
4.change的格式

         c   [number]   motion

Lesson 4

1.CTRL-G显示你在文件中的位置和文件的状态

G 移动到文件结束

number  G 移动到第number行

gg  移动到第一行

2.向前搜索phrase /phrase 
   向后搜索phrase ?phrase
   搜索之后,查找同一方向下一个出现phrase位置 n

   查找相反方向phrase出现的位置 N
   CTRL-O 到之前一个搜索的位置
   CTRL-I  到下一个搜索的位置
3.当光标在 (,),[,],{, or }处时,调到相匹配的另一个 (,),[,],{, or }出%
4.替换一行中的第一个ord为new  :s/old/new

   替换一行中的所有ord为new  :s/old/new/g

   替换行#与#之间的字符  :#,#s/old/new/g
   替换文件中所有出现的字符 :%s/old/new/g

   替换文件中所有出现的字符,并没次提示 :%s/old/new/gc

Lesson 5

1.执行外部命令 :!command

(MS-DOS) (Unix)

:!dir :!ls -  shows a directory listing.

:!del FILENAME:!rm FILENAME -  removes file FILENAME.
2. 将当前Vim文件写入到磁盘并命名为FILENAME :w FILENAME
3. 在v motion下,将所选的行保存到文件 :w FILENAME
4.将磁盘的FILENAME文件读入并放置光标之后 :r FILENAME
5.将dir命令的结果放置光标之后 :r !dir

Lesson 6

1.在光标之后打开一行,并进入插入模式 o

   在光标之前打开一行,并进入插入模式 O

2.光标之后插入文字 a

   行末插入文字 A
3.移动到一个单词的末尾处 e
4.拷贝文字 y

  粘贴文字 p
5.输入大写R进入替换模式,输入<ESC> 结束
6.输入":set xxx" 设置选项 "xxx"
'ic' 'ignorecase'       ignore upper/lower case when searching
        'is' 'incsearch'        show partial matches for a search phrase
        'hls' 'hlsearch'        highlight all matching phrases

   你可以使用长或短选项名字。
7.前面加no关闭选项 :set noic

Lesson 7

1.打开帮助窗口 :help或者按下<F1> or <Help>  

2.命令cmd的帮助 :help cmd  

3.跳到另一个窗口 CTRL-W
4.关闭窗口 :q
5.创建一个vimrc启动脚本记录你喜欢的设置
6.. When typing a  :  command, press CTRL-D to see possible completions.
     Press <TAB> to use one completion.

0 0