Initially I intended to write a single post like this one about using letters as arrows, but I couldn't help writing about other things that I believe can help IntelliJ users to be more productive, so it turned out to be enough text for three posts instead of just one.
I've been using IntelliJ for about 4 years and since the very beginning I was amazed with all the features it has for java editing. It took me a long time discover some of them. Even though there are tool-tips and productivity guide available in ItelliJ, I still say “discover” because it's one thing to read or know about some feature and it's totally different when it becomes a part of your daily work, when you use it unconsciously. One of the best demonstrations of how much you use and know IDE/editor can be trying to use another one. For me it's often a painful experience of significantly decreased productivity. It happens not because the other tools are bad or don't have some features (sometimes it's the case, though) but rather because I know some better way to do it in the favourite IDE. At the same time it's by no means an easy task to master such complicated piece of software as IDE or some powerful editor, so I believe it really pays off to be proficient with one tool you like most in order to get the best of it (see also pragmatic programmers tip 22).
Some background ideas I mainly operate in two modes when working with code:
- using keyboard with both hands on it (editing mode);
- using mouse as a pointer with the left hand on the keyboard (browsing mode).
I tend use shortcuts as much as I can, and in order to be more usable shortcuts:
- should be easy to reach (for example, Alt+F4 in Windows have never encouraged me to use it, opposed to Command-W and Command-Q on Mac which are much finger-friendly for me);
- should make my hands move as little as possible (especially in editing mode);
- often-used shortcuts should involve only one hand (it's especially useful for browsing mode; in my case it means shortcuts should be left-handed since I use mouse with the right hand).
Using alternative arrows I came across the idea of using letters as arrows in text editor when I was getting into VIM. Inspired by this idea I used for a while HJKL layout with Alt key to “switch” between letters and arrows (wikipedia says HJKL layout was initially used because Lear-Siegler ADM-3A terminal placed arrow symbols on these letters, not because someone didn't like arrows). After some time I realized that HJKL layout still doesn't feel natural for me, so I came back to using arrows. It was about a year ago that I decided to give this idea another try, but this time I used IJKL layout with some modifications. To my surprise, this time using letters as arrows felt so much better that I still use it. These are basic shortcuts I use instead of arrows (it's implied that I'm in editing mode): Alt+I – go one line up (originally Up); Alt+J – go one word left (Ctrl+Left); Alt+K – go one line down (Down); Alt+L – go one word right (Ctrl+Right); Alt+U – goto to the beginning of line (Home); Alt+O – goto to the end of line (End). Alt+N – go one character left (Left); Alt+M – go one character right (Right). I replaced going one character to the left and right in IJKL layout with going by words because I found myself doing it much more often than going by a single character. I didn't use moving cursor by a single character for some time at all, but there were cases when I just needed it, so I added those weird Alt+N and Alt+M shortcuts. Besides the above shortcuts I have similar ones but with the Shift pressed. They have the same behavior but in addition they select text. To use these shortcuts I hold Alt (and optionally Shift) with my left hand and press keys with the right hand. The main benefit of it all is that while editing I don't have to move hands to arrows. The only downside for me is that because I use IntelliJ a lot I got used to this customized IJKL layout too much, so now it doesn't feel right anymore to work in editor if it doesn't allow user to setup shortcuts like these. Note that these shortcuts for arrows work not only in the code editor but almost everywhere within IntelliJ, which proves it being an excellent example of truly consistent piece of software. Since the shortcuts for going up and down work not only in the editor but also in completion lists, I found it handy to avoid using Enter to choose an item from completion list. To choose an item from completion list I use Alt+L. So if I have code like:
objectInstance.|
I press Ctrl+Spacebar, use Alt+I and Alt+K to choose from the completion list and then press Alt+L. Besides arrows and Home, End buttons I quite often use delete button (most likely I'm not the only one %) ). To avoid moving hand to it I added to the IJKL layout these shortcuts: Alt+D – delete next word (originally Ctrl+Delete); Alt+H – delete previous character (Backspace). In addition to the above shortcuts I use these ones which are easy to reach when working with IJKL layout: Alt+8 – select next tab to the left (originally Alt+Left); Alt+9 – select next tab to the right (Alt+Right); Alt+Q – close tab (Ctrl+F4); Alt+/ – textual completion (default shortcut); Ctrl+L – smart completion (Ctrl+Shift+Enter).


0 comments:
Post a Comment