QWERTY keyboard area, via Wikimedia


Efficient use of shortcut keys, so that the fingers on the keyboard can snap flying is the key to speed up the coding speed, try to control the shortcut keys in the typing key area, can significantly reduce the movement of the wrist during the coding process, so that pressing shortcut keys more comfortable and efficient. Emacs-style keyboard shortcuts that can be prefixed to extend more typing area shortcuts are a good choice (to the disgust of non-Emacs users). This set of shortcut keys is also based on this principle. Firstly, reduce the use of function key area. On the one hand, it is easy to conflict with system shortcut keys. The editing area is a bit worse. The wrist has to move, the eye has to follow, and there are only a few default shortcuts that are not often used. The number key area is the worst, the wrist movement is the biggest, and my 87 keyboard doesn’t even have a keypad -_-, so it’s out of use. As for the mouse, it is the source of evil, the whole arm has to move, but also with the eyes to complete an operation with the mouse, the process of writing code is mostly mouse-assisted click a few times, and then go back to the typing area to continue to type, so a switch back and forth cost is too high. And programmers often click and click with their mouse? That’s not a B-box. That said, it’s not easy to go completely mouse-free, except to say that a command should be executed more than once by opening layers of menus with the mouse, the second time should be executed using Find Action, and if it’s executed more than three times a day it should be remembered with a shortcut key.

The shortcuts are custom based on Emacs Keymaps, which are much more powerful than Eclipse’s built-in Emacs Keymaps, but Eclipse has Emacs+, There are no plug-ins for Android Studio. All Android Studio has some disadvantages over Emacs, such as:

  1. Android Studio only supports a single prefix key, so mnemonic shortcuts like spacemacs are hard to implement
  2. Esc cannot be used as a modifier in Android Studio
  3. IntelliJ toEscapeCommand to configure shortcut keys, but much of the UI is hardcoded as a keyboardEscThe key. So in order to exit the floating window, alwaysC-g,EscUsed interchangeably
  4. However, the window operation logic is inconsistent, some UIs can use the moving cursor shortcut keys, others can only use the arrow keys

Some covenants, especially non-Emacs:

  • C = Control/Ctrl, if the pinky still wants to change CapsLock to Ctrl
  • M = Meta = Alt ! = Options
  • S = Shift
  • C-FIs equivalent toC-S-f, no shift character is still usedC-S-keysaid
  • Directions are indicated by ICONS:please,-,write,left
  • .Used to separate prefix keys and press first.In front of the key,loosenAnd press another key
  • For the Mac Options key, see #TODO

As for prefix keys, the following three keys are finally used:

Start by listing the most basic and important keys, especially Find Action, which is like the Run Command in Emacs and must be bound to M-x. It doesn’t matter if you can’t remember other shortcuts, as long as you remember this one, you can still do mouse-free operation, especially if it comes with shortcut hints, if any. Still, get a sense of the keywords in your commands, because search is powerful but not panacea.

Keywords in the table indicate that features can be found in the Find Action or Keymaps Settings. Custom * means that the shortcut keys are my own, non-Emacs Keymaps default configuration.

shortcuts function The keyword The custom
M-x Execute the command find Action *
C-g cancel escape
C-M-s Open the Settings settings

Move cursor

The cursor movement shortcut, which refers to the cursor movement within a single text, includes syntax-independent movement and syntax-dependent movement, which refers to the cursor movement up, down, left, and right, which is basically the same as Emacs. And c-L, even though it’s not moving the cursor, it’s still there.

shortcuts function The keyword The custom
C-f Move forward one character right
C-b Move back one character left
C-n Move up one row up
C-p Move down one line down
M-f Move one word forward next word
M-b Move one word back previous word
C-a Move to the wardrobe line start
C-e Move to the end of the line line end
C-v The next page page down
M-v The previous page page up
M-< Move to the text header text start
M-> Move to the end of the text text end
C-l Scroll the cursor position to the center of the screen scroll to center
C-Pgup Move to the beginning of the current page Page Top
C-PgDn Move to end of current page page end

Syntactically related movements:

shortcuts function The keyword The custom
C-[ Moves to the opening brace of the current Block Code block start
C-] Move to the closing brace of the current BLock Code Block End
C-M-a Move to the previous method previous method
C-M-e Move to the latter method next method

Android Studio uses m-G as the number of lines to jump to, and I changed it to the front key, as well as the front key to jump to and highlight errors.

shortcuts function The keyword The custom
M-g g As the number of lines to jump to line *
M-g n Next highlight problem next highlighted error *
M-g p Last highlight problem next highlighted error *

There is also text selection associated with the cursor. I keep c-space to add select mode, but this shortcut is also commonly used in operating systems to toggle input methods. On Linux I set the input toggle to win-space. For other systems, I recommend finding a way to leave C-space to Android Studio.

shortcuts function The keyword The custom
C-space Toggle selection mode sticky selection
C-x, h select all select all

In particular, Android Studio doesn’t have c-F options like Emacs. I can only use the traditional S-→. So it is necessary to keep c-space, with the following exceptions:

shortcuts function The keyword The custom
C-{ Select to the opening brace of the current Block Code block start
C-} Select to close the brace of the current Block Code block end
C-S-PgUp Select to the beginning of the current page page start
C-S-PgDn Select to the end of the current page page end
C-S-Home Select to the beginning of the current text text start
C-S-End Select to the end of current text text end

Navigate

Navigation, switching between different files. I use a one-step shortcut for common navigation. Be sure to use the first three, the coding efficiency is definitely a great improvement, at least not let the speed of switching files slow down your thinking.

C-m-g is an advanced version of C-M-G, jumping directly from the instance name to its class.

shortcuts function The keyword The custom
C-M-f Previous position forward *
C-M-b Next position back *
C-M-g Jump to the definition declaration
C-M-G Jump to type type declaration *
C-M-u Jump to the parent method super method *
M - please / - Switch labels left and right select tab

In addition, m-num is bound to the switch function window by Android Studio, which is very useful but not listed in one list. M-6 open Android Monitor, M-7 open Structure, and Project have better shortcut keys to open.

C-num is used to jump bookmarks. C-m-num is used to set bookmarks, which are global.

Select in… The MVP of the mouse killer, how many mouse actions are used to manipulate the current file in other forms. In most cases it is a better choice than M-Num. The default Alt+F1 conflicts with the system, so I changed it to Esc, s-i, which is easy to remember, but it’s really hard to use prefix keys for this command.

shortcuts function The keyword The custom
Esc,S-i Select from another form, such as locate the current file on the Project form select in.. *
S-Esc Hide the tool window and use it with the previous command. Hide Active ToolWindow
C-S-Esc Hide all tool Windows Hide All ToolWindow *

Edit

Android Studio has the concept of kill ring, such as M-W, C-W, M-d, and m-Backspace, but there is no Yank Pop. Paste from history… So, where did you hide the kill ring?

shortcuts function The keyword The custom
C-x,C-f Open the file file
C-x,b Switch Buffer switcher
C-x,k Close the current file close
C-_ undo undo
M-_ redo redo
C-w shear kill selected
M-w copy save to kill ring
C-y pasting paste
M-y Pasting history selection paste from history
M - S - write/left Move current row move line up/down
C - S - write/left Move the current statement/code block move statement up/down
M-; Comment the current line line comment
M-: Comment block block comment *
C-= an expand
C-M-= Expand all expand all *
C-- shrinkage collapse
C-M--) All contract collapse all *

Android Studio’s support for split panes is basically the same as Emacs, except for C-x, 0, which in Android Studio behaves the same as C-X, K.

shortcuts function The keyword The custom
C-x, 1 Close other panes unsplit
C-x, 2 Split the current pane in parallel split
C-x, 3 Split the current pane vertically split
C-x, 0 Close the current pane unsplit
C-x, o Switching between panes goto next spliteer

Find something

C-d is the default Dash shortcut for searching Dash/Velocity/Zeal

shortcuts function The keyword The custom
C-s In-text search/next match find next
C-r Next match find previous
M-% replace replace
C-S Global search find in path *
C-R Global replacement replace in path
M-S Looking for to use find usage
C-D The Dash in the search Search in Dash *

Android Studio supports macros, and there are no shortcuts for macros by default, but without C-U macros, utility is compromised

shortcuts function The keyword The custom
C-x, ( Start macro recording start macro
C-x, ) Stop macro recording stop macro
C-x, e Run the macro play last macro

Code

Extract is bound to c-m-key, which would have been a good choice, but there are too many conflicts, SO I changed it to Esc,key, which has the same first letter as the mnemonic. I hesitated between Esc and C-C, which is obviously more efficient, but I think it’s not a bad thing to pause before refactoring. So Esc was chosen.

C-[, C-] is the default function of C-[, C-], so it is better to bind to display method parameters information, after all, Android Studio code completion does not support display method parameters, so this function is also necessary.

shortcuts function The keyword The custom
M-/ Code completion, press twice to show more options completion
C-M-/ Code completion, intelligent type completion
M-enter Shows suggested behavior, class is Quick fix show intention actions
C-q Quick document quick document
C-I Quick Display definition quick definition
C-P Displays the current expression return type expression type
C-M Display method parameter information parameter info *
C-x, f formatting reformat code *
C-x, r rename rename *
C-x, i Optimization of imports optimize imports *
C-x, j Insert online templates, code completion also supports template completion insert live template *
C-x, g The generated code generate *
C-x, s Generate enclosing code surround with *
Esc, f Extract as field field *
Esc, c Extract as constant constant *
Esc, m Extraction as method method *
Esc, p Extraction as parameter parameter *
Esc, v Extract as variable variable *

Run (Make)

shortcuts function The keyword The custom
S-F10 Running the current configuration run
S-F9 Debugging the current Configuration debug
C-S-F9 Running the current Activity run context configuraton
M-S-F10 The run selection menu is displayed run
M-S-F9 The debug selection menu is displayed debug

Git

Most OF the default VCS-related shortcut keys conflict with the above configuration. Considering that there are only three M-G prefix keys for jumping, my Vcs only uses git one, I rearrange the Git-related operations using m-G prefix keys. Because it is rarely used, it may not be reasonable. I input some basic git operations directly into the Shell.

shortcuts function The keyword The custom
M-g, + Add current file add to vcs *
M-g, C-c commit commit *
M-g, C-z revert revert *
M-g, C-f fetch fetch *
M-g, C-u push push *
M-g, C-a annotate annotate *
M-g, C-p pull pull *
M-g, C-d Compare files, in the history form can be directly compared compare file/show diff *
M-g, C-D The comparison file floating window is displayed compare with *
M-g, C-h Displays the current file history show history *
M-g, C-H Displays the history of the current selected region show history *

Mouse

The mouse is still more efficient than the keyboard in some cases

shortcuts function The keyword The custom
Button2 Rectangular selection
M-S-Button1 Place multiple cursors

Live-plugin

Live – the plugin is a powerful plug-in, can give Android Studio provides a similar elisp running environment and parser, groovy script change IDE behavior at run time, the so-called InternalReprogrammability.

I changed its shortcut for running the current plug-in to the shortcut for executing elISP expressions in Emacs. The rest I haven’t used in depth yet, but I wrote a script that capitalizes words and binds them to M-C, see capitalizeWord. RegisterAction is used to add custom actions. Custom actions can be bound to shortcut keys and can be easily searched through find actions.

shortcuts function The keyword The custom
C-x, C-e Run the current plug-in run current plugin *
C-x, C-t Testing the current plug-in test current plugin *
M-c Capitalize the first letter captilazie word *

conclusion

This is just a list of shortcuts THAT I use frequently or occasionally, not a complete description of Android Studio shortcuts. There are many basic features of Android Studio that are not covered, but just for the sake of memory and sharing. This shortcut changes constantly, and you can check out the latest configuration at Douo_keymaps.

reference

Customizing IntelliJ for Emacs Compatibility