Vim Learning Assignments

Source: Internet
Author: User
Tags first string

 1. 光标在屏幕文本中的移动既可以用箭头键,也可以使用 hjkl 字母键。         h (左移)       j (下行)       k (上行)     l (右移)  2. 欲进入 Vim 编辑器(从命令行提示符),请输入:vim 文件名 <回车>  3. 欲退出 Vim 编辑器,请输入 <ESC>   :q!   <回车> 放弃所有改动。                      或者输入 <ESC>   :wq   <回车> 保存改动。  4. 在正常模式下删除光标所在位置的字符,请按: x  5. 欲插入或添加文本,请输入:         i   输入欲插入文本   <ESC>             在光标前插入文本         A   输入欲添加文本   <ESC>             在一行后添加文本特别提示:按下 <ESC> 键会带您回到正常模式或者撤消一个不想输入或部分完整的命令。
  1. 欲从当前光标删除至下一个单词,请输入:dw  2. 欲从当前光标删除至当前行末尾,请输入:d$  3. 欲删除整行,请输入:dd  4. 欲重复一个动作,请在它前面加上一个数字:2w  5. 在正常模式下修改命令的格式是:               operator   [number]   motion     其中:       operator - 操作符,代表要做的事情,比如 d 代表删除       [number] - 可以附加的数字,代表动作重复的次数       motion   - 动作,代表在所操作的文本上的移动,例如 w 代表单词(word),                  $ 代表行末等等。  6. 欲移动光标到行首,请按数字0键:0  7. 欲撤消以前的操作,请输入:u (小写的u)     欲撤消在一行中所做的改动,请输入:U (大写的U)     欲撤消以前的撤消命令,恢复以前的操作结果,请输入:CTRL-R
 1. 要重新置入已经删除的文本内容,请按小写字母 p 键。该操作可以将已删除     的文本内容置于光标之后。如果最后一次删除的是一个整行,那么该行将置     于当前光标所在行的下一行。  2. 要替换光标所在位置的字符,请输入小写的 r 和要替换掉原位置字符的新字     符即可。  3. 更改类命令允许您改变从当前光标所在位置直到动作指示的位置中间的文本。     比如输入 ce 可以替换当前光标到单词的末尾的内容;输入 c$ 可以替换当     前光标到行末的内容。  4. 更改类命令的格式是:         c   [number]   motion```
  1. Ctrl-g is used to display the current cursor location and file status information.     G is used to jump the cursor to the last line of the file.     Type a line number first and then enter uppercase G to move the cursor to the line represented by the line number.  GG is used to jump the cursor to the first line of the file.     2. Enter/Then immediately follow a string to find the string in the currently edited document. Input?     followed by a string is the reverse lookup of the string in the currently edited document.     Pressing the N key after a lookup completes the last command to find the next matching string in the same direction, or to find the next matching string in the opposite direction by uppercase N.  Ctrl-o takes you back to an older location, and Ctrl-i takes you to a newer location.  3. If the current position of the cursor is parentheses (,), [,], {,}, pressing% will move the cursor to the pair of parentheses. 4. Replace the first string in a line with old as the new string, enter: S/old/new Replace all strings in a row with old as new string, enter: s/old/new/g Replace all strings in two lines old for new words String new, enter: #, #s/old/new/g Replace all the strings in the file with old as the new string, enter:%s/old/new/g for full-text substitution, ask the user to Add c flag for each replacement:%S/OLD/NEW/GC   
 1.:!command.          Take a look at some practical examples: (MS-DOS) (Unix):!dir:!ls-Used to display the contents of the current directory.  :!del filename:!rm filename-Used to delete a file named filename.  2.: w FILENAME Saves the file you are editing in the current VIM to a file named filename.  3. V motion:w filename Saves the selected content in the current edit file in the visual mode to the file filename.  4.: r FILENAME Extracts the disk file filename and inserts it behind the cursor position of the current file. 5.: R!dir can read the output of the dir command and place it behind the cursor position of the current file. 
  1. Enter lowercase o to open a new line below the cursor and into insert mode.  Enter an uppercase O to open a new line above the cursor.     2. Enter lowercase A To insert text after the cursor position.  Enter uppercase A to insert text after the end of the line in which the cursor is located.  3. The e command allows you to move the cursor to the end of the word.  4. Operator y copies the text, p pastes the previously copied text.  5. Enter the uppercase R to enter the replacement mode until you press <ESC> to return to normal mode. 6. Enter: set xxx can set the XXX option. Some useful options are as follows:  ' ic '  ' ignorecase ' ignores letter case when searching  ' is '  ' Incsearch ' find phrase show partial match  ' HLS ' set noic         
 1. 输入 :help 或者按 <F1> 键或 <Help> 键可以打开帮助窗口。  2. 输入 :help cmd 可以找到关于 cmd 命令的帮助。  3. 输入 CTRL-W CTRL-W  可以使您在窗口之间跳转。  4. 输入 :q 以关闭帮助窗口  5. 您可以创建一个 vimrc 启动脚本文件用来保存您偏好的设置。  6. 当输入 : 命令时,按 CTRL-D 可以查看可能的补全结果。     按 <TAB> 可以使用一个补全。                          ** 启用 Vim 的特性 **  Vim 的功能特性要比 Vi 多得多,但其中大部分都没有缺省启用。为了使用更多的  特性,您得创建一个 vimrc 文件。  1. 开始编辑 vimrc 文件,具体命令取决于您所使用的操作系统:        :edit ~/.vimrc          这是 Unix 系统所使用的命令        :edit $VIM/_vimrc       这是 MS-Windows 系统所使用的命令  2. 接着读取 vimrc 示例文件的内容:        :r $VIMRUNTIME/vimrc_example.vim  3. 保存文件,命令为:        :write  下次您启动 Vim 时,编辑器就会有了语法高亮的功能。  您可以把您喜欢的各种设置添加到这个 vimrc 文件中。  要了解更多信息请输入 :help vimrc-intro

Vim Learning Assignments

Related Article

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.