Vsvim using Tutorials (and a brief introduction to VIM)

Source: Internet
Author: User
Tags function definition lowercase
1. Configure shortcut keys

1. Four modes: Normal,insert,visual,command
2. Map
   Noremap:inoremap,nnoremap, Vnoremap,cnoremap
3.Visual Studio shortcut
    (0).VsVim configuration
        defaults:use Editor Command Margin->false (Otherwise, there is a command box)
        Keyboard:set your Keyboard->include all Scopes
    (1).VsVimrc path
        home Under, _ VSVIMRC
    (2).Vs Command viewing mode:
        English environment
        view-> Otherwindow->command Window
    (3). Invoke shortcut command in vim
        : VSC vassistx.openfileinsolutiondialog<cr>
2. common commands for vim

1.normal mode
    1. move
        .Basic mobile
            j: down
            k: up
            h: left
            l: right
        Word movement
            w: word "Jump to the head of a word"
            W: WORD
            e: word's end "Jump to the end of the word"
            E: WORD's end
            ge: word's end "Jump to the end of the previous word"
            gE: WORD's end
            b: back "Jump to the head of a word"
            B: back "Jump to the head of WORD"
        .Line move
            _: Jump to the first character of a line
            0: jump to the beginning of the line
            $: Jump to the last character of the line
            >>: indent right
            <<: indent left
        Paragraph movement:
            {: Move up one paragraph
            }: Move down one paragraph
        .Screen movement
            gg: jump to the beginning of the file
            G: jump to the end of the file
            12gg: jump to line 12
            zz: the current cursor moves to the center of the screen
            zt: the current cursor moves to the top of the screen (top)
            zb: the current cursor moves to the bottom of the screen (bottom)
            c-f: turn down half a page
            c-u: page up
    2. Enter insert mode
        i: Insert before cursor
        I: Insert to the front of the line
        a: after the cursor
        A: Insert to the end of the line
        s: delete the character under the cursor and enter insert mode
        S: delete all characters of the current line and enter insert mode
        ce / cw: delete the character from the current cursor to the end of word and enter insert mode
        C: delete all characters after the current cursor and enter insert mode

        o: Insert to the next line
        O: Insert to previous line
    3. Revocation and reDo
        u: Undo
        c-r: redo
    4. Replace
        r: replace the character under the cursor with input
        R: Enter replacement mode
    5. Find:
        Single line
        f {char}: find char backward from the current cursor.
        F {char}: find char forward from current cursor
        t (char): find char backward from the current cursor, the cursor falls before char
        T (char): find char from the current cursor forward, the cursor falls after char
            ;: Next char
            ,: Previous char
        .Find throughout file
        /: Search down from the current line
        ?: Look up from current line
        *: From the current position to the word under the current cursor
        #: Find the word under the cursor from the current position up
        n: next search result
        N: Previous search result
    6. delete
        x: Cut the character under the current cursor
        X: Cut a character before the current cursor

        d {motion}: delete
        dl: delete a character under the current cursor
        de / dw: delete the character under the cursor to word end
        db: delete the character under the current cursor to the word head
        D: Delete the character under the current cursor to the end of the line
    7. Copy
        y {motion}: Copy
        yl: copy a character under the current cursor
        yy / Y: copy the current line
        ye / yw: copy the current cursor to the character at the word end
        yb: Copy the character before the current cursor to the character in word head
    8. Paste
        p: Paste after the current cursor
        P: Paste before the current cursor

    9. Dot Normal Form (.)
        .: Repeat last modification (move, delete, add)
    10. Combining commands
        yyp: copy the current line to the next line
        ddp: swap with the next line (delete the current line, copy to the next line)
        xp: swap the positions of two chrs

        yi (: Copy the content in brackets () yi {yi [yi "yi '
        di (: delete the content in parentheses () di {di [di "di '
        %: Jump matching (), (), []
    11. Modify the text
       J: Connect the next line where the cursor is located to this line with a space between them
       gJ: Connect the next line where the cursor is located to this line (the spaces in the next line are also connected)

2.Insert mode
    c-o: Enter normal mode temporarily. After one command, return to insert mode.

3.visual mode (visual (visual line, visual block))), select (select))
    Normal mode enters visual mode:
        v: character visual mode
        V: OK visual
        c-v: block visual
    Exit visual mode:
        Line / block visual v-> visual v-> normal
        Character visual mode v-> normal
        <esc> or <c-[>
    Insert in block mode:
        c-V: Enter block mode and select a good area
        I enter the block insert mode before the selected area (the inserted content will be inserted in all columns)
        A After the selected area, enter block insertion mode (the inserted content is inserted in all columns)
        c Delete the content of the selected area and enter the block insert mode (the inserted content will be inserted in all columns)
        C delete the selected area and everything after the selected area, and enter the block insert mode (the inserted content will be inserted in all columns)
        <esc> Exit to normal mode

    c-g: switch between visual mode and selection mode

    Available commands:
        Move: hjkl
        Find: f {char};, n / N
        Delete: c C d x s
    Other commands:
        o: Switch the beginning and end of the selected area
        U: Selected characters are all uppercase
        u: selected characters are all lowercase
        ~: Switch the case of selected characters

    Combination command:
    ve / vw / viw: select a word
    vu: lowercase character under cursor
    vU: capitalize the character under the cursor
    veu / U: select a word lowercase / uppercase

4.command mode
    Enter colon: in normal mode or visual mode to enter command mode
    Commands in normal mode, which can be run in command mode
    You can also run the ex command under command
    : com [mand] List all user-defined commands
    Basic command:
    : w [a] [all] write (save)
    : q [a] [all] exit
    : c [a] [all] close buffer
    : x [a] [all] and: wq are written when the file is modified

    : [range] copy / co / t {address} Copies the lines in the range to the destination address
    : [range] move {address} moves the range of lines to the destination address

    : normal command, execute the command in normal mode on the command line
    If it is in visual mode, it will render
    : '<,'> normal will execute the command on each line

5. Command range
    in .command mode
        in vim, in a single file,
        1. Use the line number as the address
        2. In addition, there are some special symbols for addresses, such as:
            % Entire file (: 1, $ short form)
            . Cursor position. current location
            1 file first line
            $ Last line of file
            0 dummy line above the first line of the file
            'm contains lines marked m
            '<Highlight the starting line of the selection
            '> Highlight the end of the selection

        Representation of ranges is separated by commas, such as add1, add2
        : 12,15d means delete 12 to 15 lines
        : [range] d [elete] [x] {count} "x into the register x"
    .normal mode
        Some commands in normal can specify the number of runs, for example:
            2dd runs twice dd-> deletes two lines
            2yy runs two yy-> copy two lines
3.mark and Jump

MX: Add this file "bookmark" x
mx: Add global "bookmark" x
' x: Jump to bookmark x row and column
' x: Jump to bookmark x row '
: Jump to the last location of the file the
GI: Jump to the location you last inserted
GV: Jumps to the last location into visual
4.Configuration of VsVim
1. Important configuration
    set backspace = indent, eol, start "backspace setting"
    set clipboard = unnamed "default clipboard register"
    set ignorecase "Ignore case"
2.Recommended configuration
        : vnoremap ci: s / ^ / \ / \ / <cr>
        : vnoremap cu: s / \ / \ // <cr>
        : nnoremap ci: s / ^ / \ / \ / <cr>
        : nnoremap cu: s / \ / \ // <cr>
    2. Related configuration
        In a single file:
        : inoremap jj <esc> "Exit Insert Mode"
        : noremap gd <c-]> zz "Jump to definition"
        : nnoremap gq == "code format"
        : vnoremap gq ==
        : nnoremap <space> za "collapse"
        : nnoremap zm: vsc VAssistX.ListMethodsInCurrentFile <cr> "Function List"
        : nnoremap cj: vsc VAssistX.FindReferencesinFile <CR> "References in current file"
        : nnoremap ca: vsc VAssistX.FindReferences <CR> "View all references"
        : nnoremap cm: vsc File.OpenContainingFolder <CR> "Open the folder"
        : nnoremap zj: vsc Edit.QuickInfo <CR> "View function definition documentation"
        : nnoremap zp: vsc VAssistX.RefactorImplementInterface <CR> "Implement the interface"

        "Find in visual mode"
        : vnoremap * "/ y / <C-r> / <CR>
        : vnoremap # "/ y? <C-r> / <CR>

        .Multi file
        : nnoremap <c-o>: vsc View.NavigateBackward <CR>
        : nnoremap <c-i>: vsc View.NavigateForward <CR>

        "Open View Class Dialog
        : nnoremap cs: vsc VAssistX.FindSymbolDialog <CR>

        "Open View File Dialog
        : nnoremap cf: vsc VAssistX.OpenFileInSolutionDialog <CR>

        "open VAOutline
        : nnoremap co: vsc VAssistX.VAOutline <CR>

        "Open Solution Explorer
        : nnoremap cv: vsc View.SolutionExplorer <CR>

        "Find in file
        : nnoremap ck: vsc Edit.FindinFiles <CR>

3. Configuration file
    source filefullPath "Read the configuration content of filefullPath and run it" 
5. Introduction and use of registers

VIM provides dozens of sets of registers for saving text for the
command to add "{register}" to  indicate the register to be used. If not specified, the default is to use the unnamed nameless register
     "x to refer to the      register x

" "      unnamed unknown register, if you do not specify the register to use, VIM will default to the register
" _      Black Hole Register (not actually stored, if "_d{motion} will perform a real delete")
0      Copy Private register  (when copying, not only will the content be copied to the unknown register, but also copied to this register) "a
-Z a   -z register (26 English letters are the name of the Register)
" +      system Clipboard Register (use +p to paste the contents of the system Clipboard) (X11 clipboard, operation with cut, copy, and paste commands)
"*      Select Private Register (X11 main clipboard, interrupt operation with mouse)
" =      The expression Register. c-r= in insert mode, enter command-line mode, and the result of entering the expression will insert the text
"%      stores the current file name
" #      stores the rotation file name
.      The last inserted text was stored
": The      last executed ex command was stored
"/the      pattern used for the last lookup was stored "

" Fyy    store copied content to F register
"FP     Paste the contents of the F Register

: Reg[ister] "{register}" to     view the contents of the {register}
6. Macros

Record the command sequence macro
the Normal,q key to start/stop recording the macro.
start recording:
    q{register} to specify which register the macro is recorded in to
stop recording:
    Press Q again, stop recording

@{register} represents the command in the execution
register @@  Repeat the most recently-called Macro
[Count]@{register} to  perform a count of times macro       serial mode
: REG {Register} View register contents

    QA  Record the key operation and overwrite the original content of the A register with the
    QA  record key operation and append to the a register in
insert mode, insert Register contents:
C-r{register}   Inserts the contents of the register into the text
. Execute macros multiple times:
    serial and parallel. In the way the error is handled, the serial encounters an error and returns.
    1. Serial
    2. Parallel
        : ' <, ' >normal @{register}
. The way the iteration is evaluated
    uses the expression register (=) for the column number to be inserted, Operations can be performed
    (do not attempt to control how many times the macro (VIM function) is executed) let
    QA 0f[ls<c-r>=i<esc>j
    : Lets i+=1
. editing macro
    macros use keyboard encoding, which is different
    if you get the register content using <c-r>{register}.
    However, you can use the way you paste the contents of the register.
    1. Output to text edit
        "{register}p        is pasted into the cursor, so use: Put output to the next line
        :p ut {register} to
        enter the register contents into the text
        After the edits are complete,
        "{register}dd       Note that under Windows, you may also paste the ^m at the end." You can delete and read the text content into the register using the Delete to register check box
    2. Use the function
        : let @{register}= ...
7. Replace

: [Range]s/{original}/{new}/[g]  g means replace all, or replace only the first one encountered
8. Tips

Ctrl+h Delete the previous character, equivalent to backspace
ctrl+w Delete the previous word
ctrl+u Delete to the beginning of the line
Num<c-a>: first encountered digit plus num 
num<c-x>: first encountered digit minus num 

: Help [   Index Assist document, all commands
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.