• VIM 初步


    按i前插入字符。a在光标后追加字符

    ctrl+d将光标下称半个窗体。按Ctrl+u将光标上移半个窗体

    在输入模式下:ctrl+h删除字符,ctrl+u删除行。ctrl+w删除字

    命令模式下。x删除字符。dw删除字,dd删除行

    u表示撤销上一个操作

    ctrl+r或输入命令:redo。表示重做

    命令dw和i能够用一条命令cw(chang world)来实现。

    命令cw能够使用VIM进入输入模式

    $ vim -r memo

    :w memo2

    可将文件另存

     

     

    dw: delete current word, but first thing for this command is the cursor has to be the first character of the word.
    d$: delete to the end of the line
    0: move to the end of the line.
    d3w: delete the 3 words after the cursor. d4w will delete 4 words
    U: To undo all the changes on a line
    p: put the line which deleted by command 'dd' under the cursor line
    r: Type rx to replace the character at the cursor with x
    ce: To change until the end of a word, type ce
    c$: Delete the context from cursor to the end of the line, and go the input mode
    ctrl+g : To show your location in the file and the file status.
    G: Go to the bottom of the file.
    gg: To move you to the start of the file.
    G: Type the number of the line you want to go and then G, this will go to the line you wann to go.

    /: search for the phrase from forward
    ?

    : search for the phrase from backward
    n: search the same phrase again, simple type n
    N: search the same phrase in the opposite direction, type N
    ctrl+o: To go back to where you came from. Repeat to go back further
    ctrl+i: To go forward
    %: to find a matching ),], or }. This is very useful in debugging a program with unmatched parentheses
    :s/old/new/ to substitute 'new' for 'old', only change the first occurrence
    :s/old/new/g to substitute 'new' for 'old', will change all the occurrences in the line
    :%s/old/new/g to change every occurrence in the whole file
    :%s/old/new/gc to find every occurrence in the whole file, with a prompt whether to substitute or not
    o: to open a line below the cursor and place you in insert mode.
    O: to open a line above the cursor and place you in insert mode.
    a: to insert text AFTER the cursor
    i: to insert text BEFORE the cursor
    A: to insert text at the end of line
    R: replace more than one character
    r: replace one character of cursor position

    copy and paste: 
    1. start visual mode with v and move the cursor to select the text you want to copy
    2. Type y to yank(copy) the highlighted text.
    3. Go to the position which you want to paste your text
    4. Type p to put(paste) the text

    set option:
    :set number(set nu): show up line number
    :set ic: set ignores case when searching or substitute
    :set hls is: set lisearch and incsearch option
    :set noic: disable ignoring case 
    if you want to ignore case for just one search command, user c in the phrase: /youStringc

    版权声明:本文博客原创文章。博客,未经同意,不得转载。

  • 相关阅读:
    html基础之html标签
    unittest框架(二)单元测试及测试报告
    unittest框架(一)用例管理
    python实现http接口自动化测试(完善版)
    python学习笔记(二十九)为什么python的多线程不能利用多核CPU
    深入理解JVM(三)——配置参数
    深入理解JVM(二)——内存模型、可见性、指令重排序
    深入理解JVM(一)——基本原理
    做了两款数据库监控工具,打算在近期开源
    电商系统中的商品模型的分析与设计—续
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4628348.html
Copyright © 2020-2023  润新知