Ideavim Plug-in Use tips _idea

Source: Internet
Author: User
Tags class definition lowercase sublime text
The idea IntelliJ tips and plug-ins in the article briefly introduced the Ideavim plug-in. Here is a detailed summary of the plug-in in the day-to-day programming of some of the common tips. For interested in using this plugin, but Vim is not very familiar with the friend reference. Of course, the basic concepts of HJKL moving cursors and several common patterns are skipped.

In order to ensure that only common operations are included, the techniques mentioned here are not copied from ready-made documents, but are listed by memory (not usually remembered by nature). It is expected to be omitted and added slowly.

1. Toggle VIM Emulator State

This plug-in allows you to set a shortcut key to open or close, in the switching mode will also automatically switch keymap, very convenient. The default is CTRL+ALT+V, but this button covers the most commonly used "extract local variables" function, the proposed reset, in Setting->keymap to find vim emulator can.

Since the opening and closing states use two sets of keymap respectively, so both sets need to be set. Two sets of keymap can be set to the same key, that is, with the same key switch. But personal advice is set to a different key so that you know exactly where you are currently in that pattern. Also, if the Vim simulator is turned off in Vim's insert mode, the next entry is still in the insert mode, which is confusing (because you turn off the simulator to use the default Keymap to enter large sections of code and reopen the VIM emulator to use Normal mode commands). It is therefore advisable to set the exit Insert mode in Vim keymap to the same key as the other keymap vim emulator (that is, the shortcut key to the VIM emulator). For example, the settings I use are:
Default keymap-> Vim emulator:ctrl+; (Use CTRL + Semicolon to open the Vim simulator)
Vim Keymap-> vim emulator:ctrl+, (Close vim emulator with CTRL + comma)
Vim Keymap-> vim emulator:ctrl+; (Use CTRL + Semicolon to exit insert mode, into normal mode)
This way, you can guarantee that you will be in normal mode of the Vim simulator at any time by pressing CTRL + semicolons.


2. Scrolloff parameter
After starting IntelliJ, enter a command under the VIM emulator: Set so=5 can make the screen scroll to keep 5 lines of preview code below the cursor (that is, the cursor will trigger the scroll up on line 5th, or the bottom 5th line to trigger downward scrolling). This is handy when the code window is small, such as step-tracking debugging. Unfortunately, it works only when the Vim simulator is turned on.

3. Line number positioning
In normal mode, enter line number G or: line number < carriage return > can quickly navigate to a row. The difference is that the former does not have any prompts on the screen when entering line numbers, and the latter can see the input process in the VIM command input box. (digression: Sublime Text 2 is also used: line number to quickly locate to a line, should be followed the habit of vim)

4. Entry modification
There are many ways to enter the insert mode, and it is better to enter the insertion mode directly than to move the cursor with the arrow keys after entering. Commonly used are:
O-Inserts a new row below the current line and indents automatically
O-Inserts a new line above the current line and indents it automatically (in normal mode, uppercase commands are entered with the shift+ letter key, below)
I-inserts a character at the beginning of the current character Fu Zofang
A-inserts a character to the right of the current character
I-the cursor moves to the beginning of the line and enters insert mode
A-the cursor moves to the end of the line and enters insert mode
S-Deletes the cursor's character and enters insert mode
S-Deletes the cursor line and enters insert mode
c< Range >-Deletes a range of text around the cursor position and enters insert mode. For the scope, see 5th, commonly used combinations are: CAW-Deletes a word including its trailing spaces and starts inserting; CIW-Deletes a word and begins inserting; CI "-Deletes a string inner text and starts inserting; C $-Deletes from the cursor position to the end of the line and begins inserting; Ct character-delete from cursor position To begin inserting, except for one character in the bank (keep the character). Wait a minute.
C-Deletes the cursor position to the end of the line and enters insert mode (equivalent to C $)
R-Modify the character of the cursor and return to normal mode
R-Enter Overlay mode

5. Scope operation
Some normal-mode action commands can be appended with a range of instructions to indicate that the action will function across the scope. Such commands are commonly used in:
d< Range >-delete text within a certain range
c< Range >-delete certain range of text and enter insert mode
y< Range >-place text in range into the No. 0 and "Registration Bar"
v< Range >-Select text in range
=< Range >-Automatically indent text in range
gu< Range >-Converts a range of characters to uppercase
gu< Range >-Converts a range of characters to lowercase
>< Scope >-Indent the contents of the range into one grid
<< Scope >-Indent the contents of a range to one grid

The commonly used range directives are:
Space-the character where the cursor is located. (for example, GU space-converts the cursor position character to uppercase)
Repeat certain action commands-the line where the cursor is located. (for example, DD deletes a row, yy duplicates a row, CC deletes a line of text and begins inserting,>> the current line indents a grid, = = automatically indents the current line)
$-from the cursor position to the end of the line
^-from the cursor position to the beginning of the line, does not contain indentation whitespace
0-from the cursor position to the beginning of the line, including indentation whitespace
GG-from the cursor position to the beginning of the file
G-from the cursor position to the end of the file
%-bracket matching from cursor position to other side
f< character >-the position of the first occurrence of a character from the cursor position to the right of the cursor, including the character
f< character >-the position of the first occurrence of a character from the cursor position to the left of the cursor, including the character
t< character >-the position of the first occurrence of a character from the cursor position to the right of the cursor, including the character
f< character >-the position of the first occurrence of a character from the cursor position to the left of the cursor, including the character
/Regular expression-from the cursor position to the next matching regular expression (across rows)
? Regular expression-from the cursor position to the position of the last matching regular expression (cross row)
AW-a Word plus a space (a can be understood as "one", same below)
IW-A word (I can be understood as in, the same below)
A "-a string containing double quotes
I "-a string of internal text
a<-A set of < > included text, including < > number itself
Analogy: I&lt, a[, i[, A (, I (
Note: The IT scope in true vim (within a pair of XML tags) does not take effect in Ideavim.

When you use the/or? Command lookup, the regular expression is the default case sensitive, and if you need to be insensitive, you can add the \C flag at the beginning of the regular expression. For example/\CABC can match to ABC. The following mentioned: The S command also applies.

6. Select text
In Vim, the choice of text needs to go into visual mode, a strange name, which is said to be because in the predecessor VI of VIM, the selection area is not visible. Selecting a region in Vim is highlighted and is therefore called "visual mode."
V-Enter character selection mode, V-Enter row selection mode, CTRL + C-Enter block selection mode.
Move the cursor after entering the appropriate mode to select the text. You can press the O key during the procedure to toggle the cursor at both ends of the selection.
Select multiple rows in block selection mode, then enter text after I or a, and then exit Insert mode, and the text you enter is automatically added to the beginning or end of each line.

7. Copy and paste
In vim mode, copying and pasting does not directly use the system's clipboard, but instead uses several "registers" provided by Vim, each of which is represented by a single character. A detailed description of the register can be seen here http://blah.blogsome.com/2006/04/27/vim_tut_register/(a random Google page), here a simple list of some common operating techniques (note that VIM uses double quotes As a command to select registers, so the double quotes in the following section refer to the double quote key in normal mode:

A) using the Y command to store the text in the register, if you want to replace the original content elsewhere, you can first select the original content with the V command, and then paste with the P command. But after the first paste, the default register "will be replaced with what you just deleted." If you want to paste the copied content again, you need to use the 0p command combination to copy it. You can also go into insert mode and copy with Ctrl+r 0来, for example, the CIW&LT;CTRL+R&GT;0 command combination replaces a word at the cursor with the pasted content and stays in insert mode.

b in Windows, registers + and * Both represent the system Clipboard, can be used interchangeably, choose a conveniently.  For example, the +YY command combination can copy the current row to the system Clipboard. CI the <ctrl+r>* command combination replaces the contents of the system Clipboard with the inner text of the string.

c) Registers 1 to 9 record nine times before the deletion of large pieces of text, each time more than one row of the deletion will cause the contents of the 9 registers are offset, the most recently deleted text will be stored in register 1. However, only the deletion of more than 1 rows will affect registers 1 to 9, and the deleted content in the row will be credited to the register-(minus sign). If you record a macro with the Q command without a cross row deletion, you can use the 9 registers directly in the macro to temporarily hold the text. (in vim, the copy content shares the same set of registers as the recording macro, so I'm used to leaving the alphabet registers with the macros)

D in normal mode, lowercase p copies the register contents to the current position, and capital P copies the register contents to the current position.

e) Use: regs command to list the contents of all current registers

8. Some common shortcut keys in insert mode
CTRL+H-delete cursor left character
Ctrl+w-Deletes the word to the left of the cursor
Ctrl+y-A character above the copy
Ctrl+e-Copy one of the characters below
Ctrl+r 0-To insert the previous contents of the Y command
Ctrl+r *-Inserts the contents of the system Clipboard
Ctrl+r < register name >-Inserts the contents of the specified register
CTRL + A-inserts what you typed in the previous insert mode
Ctrl+o-Executes a command in normal mode and returns the Insert mode. For example Ctrl+o A is equivalent to pressing the END key, Ctrl+o I is equivalent to pressing the home key

9. Exit Insert Mode
You can exit insert mode with the ESC key, but the keys are too far. In fact, you can also use the ctrl+[key to exit insert mode. Of course, you can also use the 1th custom CTRL +; shortcut keys, but this is not a standard VIM button, will develop bad habits, do not recommend use.

10. Repeat operation
Press in normal mode. (decimal point) to repeat the last modification action
&-Repeat Last: s substitution command
@@-Repeats the last macro that was executed

11. Jump
CTRL +] jumps to the defined position of the current identifier (equivalent to holding down CTRL with the mouse click on the word at the current cursor position)
Ctrl+o back one step (go)
Ctrl+i before further (go forward)
`. Jump to previous modified location
"Toggle between the previous jump position and the current position
Line number G or: line number < Enter > jump to a row
GG jumps to the beginning of the file
G jump to end of file
H jump to the top of the screen (if set so=n, then jump to Nth line)
L jump to the bottom of the screen (if set so=n, then jump to the penultimate nth line)
M jumps to the middle of the screen
F or F jump to a line of characters, lowercase f lookup to the right, uppercase F to the left. use; or, toggle between matches
T or T jumps to a character in the bank, the lowercase t looks to the right, and the capital T looks to the left. use; or, toggle between matches
/Regular expression jumps to the next match. Toggles between matches with N or N.
? The regular expression jumps to the previous match. Toggles between matches with N or N.
(combined with the previous 5th, you may notice that, in the specified range, the jump command will specify a range from the cursor position to the jump target)

12 bookmarks
In normal mode, press m< lowercase > to define a bookmark, press ' < letter > to jump to the exact position of a bookmark, press ' < letter > ' to jump to the beginning of a line of a bookmark (useful for recording a macro). The most commonly used natural is the MM, MN, MJ, MK, ML these several handy keys.
The global bookmark in true vim m< uppercase > does not take effect in the current Ideavim version. Need to define a global bookmark you can use Idea's original F11 + digital method

13 Text Replacement
Using: s/Regular expression/alternate text/Can replace the first occurrence of the match within the bank
Using: s/Regular expression/alternate text/g Replace all occurrences within the bank
Using:%s/Regular expression/alternate text/g replace all occurrences in the current file

When text is selected in Visual mode, use: ', ' >s/regular expression/alternate text/g command to replace text in the selected area. where ', ' > part in Visual mode, press: After the colon automatically joined, directly enter the S command. But the effective area can only be in the ACT unit. The \%V flag in true vim does not take effect in Ideavim.

11 Code Folding
Zo-Open Folding
ZC-Close Folding

14 Macro Definitions
Defining macros in Ideavim is a lot lighter than idea's own macro function. Press the q< register name > in normal mode to begin recording subsequent key sequences to the specified registers (register reference 7th above). Recording is completed into normal mode and then press Q to stop recording. It can then be replayed with the @< register name >. Note that macros and copy-and-paste share a set of registers, so when you record a macro, be careful not to copy the registers that the current macro is using. The register contents are automatically saved and the reset idea is still in effect. However, Ideavim does not export the ability to save macros independently. So it is best to separate the registers used to hold macros from the registers that are used to copy and paste them, and not the same registers are sometimes used to record macros, sometimes to copy and paste. My habit is that the left-hand side of the keyboard is used to hold some long term macros (for example, I have a macro that extracts the version number in the Pom.xml to the property area, and the original location uses the ${property} reference). The HJKLNM key in the right-hand area is used to hold some temporary macros. YUIOP Five registers are reserved for copying and pasting. Registers 1 through 9 can also be used for copy and paste if the recorded macro does not involve deleting large pieces of code.

Once a macro is executed, you can repeat the last macro that was executed with the @@ 命令.

When you record a macro in idea, if the code is triggered automatically, the characters entered in the status of the automatic completion list are not recorded. It is therefore preferable to set the delay to 500ms or shut down in the setting-> code completion-> autopopup code completion. Avoid triggering code completion in the process of recording macros.

When you record some long-lived macros, it's a good idea to use 0,^,t, F, $, and so on to align the cursor to the end of the line or to a specific starting position (say, "Jump to the left quotation mark with F"), and then jump to the operation position with an F or/instruction. Such macros do not have to have the cursor placed on a particular character to use.

15. Some common combination techniques
Select All: GGVG
Swap two character positions: XP
Copy one line: YYP
Swap two lines: DDP
In insert mode, continue to enter at the end of the line (equivalent to the ending key): Ctrl+o A or ctrl+[a
Insert mode continue to enter at the beginning of the line (equivalent to the home key): Ctrl+o I or ctrl+[i
To the class definition location (applicable to the Public,protected class that is correctly indented):? ^p carriage return

16. Some common vim features that are not implemented in the current version
(Skip this section if you are unfamiliar with vim)
A The Let command (cannot export/import register contents without a We command, i.e. cannot import macros)
b): G command (a very useful command in text processing, which is less common in programming)
c)! command (execute shell command)
D) Most regular expression markers (e.g. \%v, \v, etc.)
e) Some of the multiple key commands double-click the last character representation to act on the current line. For example, in Vim, GUU can convert the current row to uppercase, and in Ideavim, you can do the same function by selecting the current row with the V command, and then converting the GU to uppercase.
F Most commands on window operation (CTRL+W series command,: Split, etc.)
G All Vim scripting Plug-ins (though most can be compensated with idea's own functions and plug-ins)


Well, almost forgot, in normal mode, press U to undo the last modification (equivalent to the ctrl+z of other Ides) and redo the revoked changes by Ctrl+r.

from:http://kidneyball.iteye.com/blog/1828427

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.