vimtutor学习笔记

lesson 1 SUMMARY

  1. The cursor is moved using either the arrow keys or the hjkl keys.
         h (left)       j (down)       k (up)       l (right)
# 上下左右移动
  2. To start Vim from the shell prompt type:  vim FILENAME <ENTER>
# vim filename 打开文件
  3. To exit Vim type:     <ESC>   :q!   <ENTER>  to trash all changes.
             OR type:      <ESC>   :wq   <ENTER>  to save the changes.
# :q!退出,:wq保存
  4. To delete the character at the cursor type:  x
# x删除字符
  5. To insert or append text type:
         i   type inserted text   <ESC>         insert before the cursor
         A   type appended text   <ESC>         append after the line
# i插入,A行尾插入

lesson 2 SUMMARY

  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
# 删除使用 d motion,dw删除字符,d$删除到行尾,dd删除一行
  4. To repeat a motion prepend it with a number:   2w			# 移动两个字符
  5. The format for a change command is:									# 操作格式一般是 操作符 数字 动作
               operator   [number]   motion
     where:
       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. To move to the start of the line use a zero:  0
# 移动到行首
  7. 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								# undo重做

lesson 3 SUMMARY

  1. To put back text that has just been deleted, type   p .  This puts the
     deleted text AFTER the cursor (if a line was deleted it will go on the
     line below the cursor).
# p把删除的东西再打印出来
  2. To replace the character under the cursor, type   r   and then the
     character you want to have there.
# r替换字符
  3. The change operator allows you to change from the cursor to where the
     motion takes you.  eg. Type  ce  to change from the cursor to the end of
     the word,  c$  to change to the end of a line.
# c是修改,c$是删除光标到行尾的所有字符
  4. The format for change is:
# c可以后面跟数字,动作类型
         c   [number]   motion

lesson 4 SUMMARY

  1. 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.
# G移动到文件结尾, 数字 G 移动到某一行, gg移动到文件第一行
  2. 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.
# /是向后搜索,?号是向前搜索, n是下一项(向前搜就向前一项,向后搜就向后一项) N是上一项。
# CTRL-O 是跳转到上一个光标的位置,CTRL-I是反操作
  3. Typing  %  while the cursor is on a (,),[,],{, or } goes to its match.
# %是跳转到对应的匹配,对应的括号来回跳,之前都不知道。这个太方便了。
  4. 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
# 字符替换:s/old/new替换当前行第一个,:s/old/new/g替换整行,:%s/old/new/g整个文件替换,:%s/old/new/gc整个文件替换并需要确认

lesson 5 SUMMARY

  1.  :!command  executes an external command.
# 使用!命令 执行shell命令
      Some useful examples are:
         (MS-DOS)         (Unix)
          :!dir            :!ls            -  shows a directory listing.
          :!del FILENAME   :!rm FILENAME   -  removes file FILENAME.

  2.  :w FILENAME  writes the current Vim file to disk with name FILENAME.
# :w 文件名 会保存一个新的文件
  3.  v  motion  :w FILENAME  saves the Visually selected lines in file
      FILENAME.
# v 动作 加上:w 文件名 会保存选中的内容到新文件里
  4.  :r FILENAME  retrieves disk file FILENAME and puts it below the
      cursor position.
# :r 文件名 可以把文件中的数据读取出来写到光标的位置
  5.  :r !dir  reads the output of the dir command and puts it below the
      cursor position.
# :r !命令 可以把shell命令执行的结果写进文件里      

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.
# 使用o向下新增一行,使用O向上新增一行
  2. Type  a  to insert text AFTER the cursor.
     Type  A  to insert text after the end of the line.
# 使用a在光标后进入插入模式,使用A在text末尾进入插入模式
  3. The  e  command moves to the end of a word.
# 使用e命令移动到单词的尾部
  4. The  y  operator yanks (copies) text,  p  puts (pastes) it.
# 在visual模式下,使用y复制text,使用p粘贴
  5. Typing a capital  R  enters Replace mode until  <ESC>  is pressed.
# 使用R来实现进入替换模式,ESC来退出,每次替换都是替换已有的字符
  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.
# 使用:set xxx来执行设置一些选项,如ic是忽略大小写比较,is显示搜索短语的部分匹配项,hls搜索高亮
  7. Prepend "no" to switch an option off:   :set noic
# 在:set xxx前增加no来关闭选项

lesson 7 SUMMARY

  1. Type  :help  or press <F1> or <Help>  to open a help window.
# 按F1寻求帮助
  2. Type  :help cmd  to find help on  cmd .
# 输入:help同样能打开帮助
  3. Type  CTRL-W CTRL-W  to jump to another window
# CTRL-W CTRL-W 可以在不同窗口跳转
  4. Type  :q  to close the help window
# :q 退出帮助窗口
  5. Create a vimrc startup script to keep your preferred settings.
# 可以创建一个vimrc的设置脚本在vim启动时,~/.vimrc
  6. When typing a  :  command, press CTRL-D to see possible completions.
     Press <TAB> to use one completion.
# 在输入:x 收,输入CTRL-D查看所有可能的匹配参数,按TAB一个一个匹配
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

习惯就好zz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值