How to minimize use of arrow keys when typing code?

后端 未结 11 1207
灰色年华
灰色年华 2021-02-05 10:23

When typing code, I would normally close brackets, go back inside, go outside, type semicolon, etc:

I might start with (| is the caret):

System.out.print         


        
相关标签:
11条回答
  • 2021-02-05 10:49

    Try AutoHotKey and my script:

    *!I::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Up}"
    *!K::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Down}"
    *!J::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Left}"
    *!L::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Right}"
    *!U::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Home}"
    *!O::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{End}"
    *!h::SendInput, % (GetKeyState("Shift", "P") ? "+" : "") (GetKeyState("Ctrl", "P") ? "^" : "") "{Del}"
    

    LAlt & Shift:: ('optional line')

    It's about holding LAlt + pressing something from: i, k,j, l (arrow keys), u, o (home, end) or h (delete). Last line is optional if you don't want to change keyboard lang. layout by LAlt +Shift

    You can use it even in combination with modificators like shift and ctrl.

    enjoy ;)

    0 讨论(0)
  • 2021-02-05 10:51

    If you're already in vim, try playing around with the h,j,k, and l keys. They do the same thing as the arrow keys but are much more convenient. Trying to get in the habit of typing in order would probably also help, but that's something that takes some effort.

    0 讨论(0)
  • 2021-02-05 10:52

    Well, that's Java, If you use a more or less good IDE you should be able to autocomplete, that way when you type "System.out.println" and hit enter to accept autocomplete, the brackets will show up and the caret will be in the middle (oh, and there will be the quotes too!)

    0 讨论(0)
  • 2021-02-05 10:56

    I find the number pad makes navigation very easy because the home and pgup keys are so close. For actually typing numbers you just use the top row of the keyboard (which is difficult to learn I agree but sufficiently fast after a while).

    The only downsides of this for me are using laptop keyboards and using other people's machines where I have to turn off num lock every time.

    0 讨论(0)
  • 2021-02-05 10:58

    A good IDE (galileo is almost here) will auto close brackets, parentheses, etc, and will intelligently insert a semicolon at the end of the statement too. No need to use arrows at all!

    Of course for a println in Eclipse you can just type sysout but that's probably a bad habit to get into.

    But be careful! If you get too quick your colleagues will always make you drive :P

    0 讨论(0)
  • 2021-02-05 11:00

    Another vote for Vim. Also, there are some great plugins for more standard IDEs that use Vi keybindings. I use jVI in Netbeans from time to time.

    You'll find that the more you use Vim, the easier it is on your wrists. You'll also find that a sufficiently clever find/replace can save you quite a few keystrokes, as can a global action regex-y thing.

    Bind :tabn and :tabp to something accessible like and and force yourself to get stuff done without giving up and using a proper GUI editor.

    0 讨论(0)
提交回复
热议问题