vim commonly used shortcut keys (finishing version)

Edit mode

  • o open a line below
  • i insert
  • a app

  • I insert a line before
  • A appen a line below
  • O appen a line above

Global Replace (Java replaced by Python)

    % s/Java/Python/g

Syntax Highlighting

    syntax on

Visual mode

  • v Select mode
  • Select an entire row V
  • ctrl + v multiline

Insert mode Tips

How to quickly repair the wrong

  • ctrl + h to delete a character
  • ctrl + w to delete the word
  • ctrl + u delete the entire line

Enter the last edit location (insert mode)

give

vim fast-moving

  • Hjkl against humanity

Moving between words

  • W moved to the beginning of the next word
  • e to move the end of the next word
  • b move to the beginning of a word (backword)

Interline movement (moving to the Bank Search character position)

  • f {char} char character to move
  • F {char} char character reverse search Bank
  • t {char} char character moves to the front

The horizontal movement

  • 0 move to the first character of the line
  • ^ Move to first non-blank character
  • End of the line to move $
  • g_ end of the line to move non-blank

Move the paper

  • gg quickly move to the beginning of the file
  • G quickly move to the end of file
  • H / M / L is moved to the beginning of the file quickly, middle, and end
  • ctrl + u / ctrl + page up / down on f
  • The intermediate screen placed zz

To delete a character

  • dw delete word
  • dd delete the entire line
  • dt delete to ( "delete characters between the quotation marks in parentheses
  • 4x deletes four characters

Vim to quickly modify

  • r replace a replacement character
  • c change cw (change word) change the whole word
  • After insertion into the replacement character s substitute

Vim inquiry

  • Use / or? Front or reverse search to
  • The use of n / N, or a jump on a match
  • Use * or # for the current word forward and backward match

Vim Replace command

  • substitute find and replace text, regular support
    :[range]s[unstitute]/{pattern}/{string}/[flags]
  • range indicates a range, such as: 10 and 20 represent lines 10-20, all expressed in%

      :1,10 s/java/Java/g //替换1-10行
      :% s/java/Java/g      //替换全部
  • pattern is to replace mode, string is the text after replacement

  • flags replacement flag

    • g (global) represents performed globally
    • c (confirm) represents confirmation may confirm or reject changes
    • The number n (number) to report the match is not replaced.
  • Regular replacement

      :% s/\<java\>/Java/g  //精确替换前后字符

Vim Multiple Documents

  • file buffer cache
    • Use: ls include the current buffer,: bn jump to n-th buffer regions
    • :bpre :bnext :bfirst :blast
    • : B buffer_name plus tab completion to jump
  • window window
    • <ctrl + w>w
    • <ctrl + w>hjkl
    • vs split window
  • tab organize multiple windows
    • tabnew new tab workspace
    • gt & gT switch workspaces

Vim's Text Object

  • Operation text object

      [number]<commond>[text object]
    
      例如:ciw ci) ci" ci'
    • number indicates the number of
    • command 命令 d(delete) c(change) y(yank)
    • text object text object w (word) s sentence paragraph p

vim register and copy-paste

  • y (yank) yy Copy Copy Copies the entire one word line yiw
  • p (put) Paste

  • Copy and paste in insert mode
    • After autoindent set up automatic indentation, formatting will be chaos
    • set paste and set nopaste solve
  • Common register
    • "Before copying + plus clipboard can be copied into the system
    • set clipboard=unnamed

Powerful vim macros (macro)

  • Macro set of q q start a series of commands end
  • qa recorded in a register open end of the recording aq
  • Performing a plurality of rows select all V + G, enter the command line
  • normal @a record a macro execution

Vim completion

  • ctrl + n or complete words ctrl + p
  • ctrl + x or ctrl + f filename completion
  • ctrl + x ctrl + 0 or completion codes, for an extension.

Vim color

    :colorschemes       //显示当前主题    
    :colorschemes <ctrl+d>  //显示所有主题
    :colorschemes name      //更换name主题

Vim basis END

  • VIM for editing using bare
  • Practice touch typing
  • IDE plugin VIM increase
  • Muscle memory

Guess you like

Origin www.cnblogs.com/maozhe/p/11957251.html