zoukankan      html  css  js  c++  java
  • Learning.the.vi.and.Vim.Editors

    Simple Editing

    两种模式:命令模式和插入模式.

    ESC退出到命令模式, i进入插入模式.

    1. 光标的移动

    0(数字): 移动光标到行首

    $: 移动光标到行尾, 2$: 移动光标的下一行的行尾, 4$= 3j + $

    h: 左移一个光标

    j: 下移一个光标

    2k: 上移两个光标

    4l: 右移4个光标

    +: 转到下一行的首字符

    -: 转到上一行的首字符

    b or B: 前一个单词(或当前单词)词首, 大写B: 前一个单词的词首, 不算计数符号和标点符号

    e or E: 后一个单词(或当前单词)词尾

    w or W: 后一个单词词首, , 大写W: 后一个单词的词首, 不算计数符号和标点符号

    G: 移动要一个特定的行, 可以使用G命令. G移动到文件末尾, 1G移动到文件开头, 43G移动到43行. 

    2. 简单的编辑

    注: 前面加上数字,表示多次执行该命令.

    i for insert; a for append; c for change; and d for delete.

    move text with a d for "delete", then a p for "put".

    copy text with a y for "yank", then a p for "put".

    i: (insert)在光标前处插入

    a: (append)在光标后插入

    c: changing text, leave you in insert mode until u press the ESC key.

    cw: To the end of a word

    c2b: Back two words

    c$: to the end of line

    c0: to the beginning of line

    Words

    cw: delete the word marked and insert new text until ESC is pressed

    Lines

    cc: replace the entire current line until ESC is pressed.

    C=c$: replace characters from the current cursor position to the end of the line.

    Characters

    x: delete only one or 2 characters.

    r: replaces a single character with another single character. U do not have to press ESC.

    Substituing text(替换文本), leave u in insert mode

    s: replace a single character

    S: replace wholes lines.

    R: enters overstrike(覆写) mode. leave u in insert mode.

    Changing Case

    ~: change a lowercase letter to uppercase or an uppercase letter to lowercase.

    Deleting Text

    dw: delete by word, 删除当前光标 至 下个单词开始字符 之间的所有字符, 包括空格.

    de: 删除当前光标 至当前单词的最后一个字符. 不包括后面的空格(如果有的话)

    dE: 同上, 不过它将标点符号视为普通字符, 如 "text,abc" 如果逗号后面没有空格的话, 该命令视其为一个单词来删除.

    dd: delete the entire line that the cursor is on.

    D=d$: delete from the cursor position to the end of the line.

    Moving text

    just like a "cut and paste"

    p: puts the text that is in the buffer after the cursor position.

    P: puts the text before the cursor

    Transposing(调换,互换) two letters

    xp: delete character and put after cursor

    Copying Text

    y for yank and p for put.

    yy: copy an entire line

    Y=yy; Notice is not same as D=d$ & C=c$;

    Repeat command

    .(the period): repeat the same editing command

    Undo

    u: undo your last command

    U: undo all edits on a single line, as long as the cursor remains on that line. Once you move off a line, you can no longer user U.

    Redo:

    CTRL-R: redo an undone operation.

    some other insert commands for inserting text at different positions relative to the cursor:

    注: 除了R之外, 其余几条命令执行后, 均处于insert模式

     A: Append text to end of current line

    I: Insert text at beginning of line

    o(小写字母o): 在当前光标的下一行插入新行

    O(大写字母o): 在当前光标的上一行插入新行

    s: 删除当前光标下的字符, 并且替换text. 进入insert模式, 相当于xi.

    S: 删除当前行, 替换为新text. 相当于0D.

    R: 用新字符覆写旧字符. 进入replace 模式, 可使用bakespace先前移动光标, 且恢复覆写内容.

    插入命令的数字参数

    50i*ESC: 插入50个星号

    25i*-ESC: 插入50个字符, 25对"*-"

     Joining Two Lines with J

    J: 连接当前光标所在行和下一行 成一行, 之后, 光标位于连接处(第二行的第一个字符处)

    在.vimrc中设置显示行号: set nu, 或在命令模式输入":set nu"

    实用中文帮助手册:http://yangbo.name:88/wp_page/vi/

    英文帮助手册: http://vimdoc.sourceforge.net/htmldoc/

  • 相关阅读:
    Mac使用笔记(二)
    AJAX tooltip by jQuery UI Widget and MVC3
    MVC4的bundling功能简介
    Mac使用笔记
    浅析ASP.Net Web API的Formatter
    浅析ASP.net Web API的Model验证(使用MVC4框架的Web API须谨慎)
    2012年读过的最好的书
    SQLite在.net下的使用方法
    C#也允许函数默认参数
    chrome不支持对opener方法的调用?
  • 原文地址:https://www.cnblogs.com/xlmeng1988/p/2535191.html
Copyright © 2011-2022 走看看