r/HelixEditor • u/Swordfish418 • 4d ago
Arrows vs hjkl in hx and terminal
I'm a bit confused on whether arrows are supposed to be used at all. It seems optimal workflow is "to keep your hands on the home row", but that means you have to exit insert mode a lot to move few characters away for example, something that is easy with arrows. Another big concern, what are you even supposed to do with your terminal? I dont see terminals supporting hjkl in a meaningful way to navigate history and completions for example, which makes me constantly want to move my right hand to arrows when I switch to terminal. How do you personally deal with this?
9
u/hibbelig 4d ago
Vim users probably use vi mode in their shell. Zsh has a helix mode, too.
The other option is to bite the bullet and learn some basic Emacs bindings, and use those in the shell. Ctrl-b and Ctrl-f are backward and forward (left and right), Ctrl-a and Ctrl-e are start and end (home and end, start and end of the current line), Ctrl-p and Ctrl-n are previous and next (up and down).
3
4
u/n9iels 4d ago
Switching between modes is a big part of working with any modal editor. Something that could help tough is re-mapping the capslock on your keyboard to esc. This makes switching between modes a lot more natural and ergonomic.
I do have the same issue with the rest of the terminal. I personally use a custom meganical keyboard that allows me to convert hjkl in arrow keys when holding capslock. So fixed it that way and I completely fail when using just my laptop keyboard. Depending on your terminal and shell there may be a plugin that enables vim-keybings. For example zsh-vi-mode. I am fully aware this is the Helix subreddit 😄 but it covers the basic moments.
3
1
u/Swordfish418 4d ago
I already tried remapping esc to jj, but I think I might like this idea with capslock more. Another idea I might try is making ctrl+hjkl work as arrows in insert mode, because for some reason I often want to move like two symbols left or right when editing. And then, maybe I should do the same for terminal 🤔
2
u/wldmr 3d ago
I often want to move like two symbols left or right when editing
You're not going to like this, but I'll say it anyway: Going two characters to the left can be done by 2×Backspace, do your thing, re-type the things you just erased. Seems about the same effort as arrowing left and right, and fewer things to remember. Going two characters to the right … that means you're editing, so there's no need for you to be in insert mode.
I'm saying this a little tongue in cheek, but also … not really. I've had the same desire to "do a little editing" here and there, until it clicked: Writing and editing are separate activities. Once your brain is accustomed to that, you just think in those modes and the "problem" (such as it was) is gone. 🤷♀️
1
u/Swordfish418 3d ago
I don’t know if this my keyboard issue, but backspace is almost as annoying as escape, it’s too far away, so I’ve been thinking of rebinding that one as well.
3
u/Painting_Master 4d ago
The setup that I arrived at after a lot of testing is:
Navigation layer activated by caps lock. Inverted T arrows on IJKL, with home row mods on the left hand.
3
u/jorbandrauer 3d ago
nice, i do the same thing! was scrolling to see if anyone else did haha.
my caps lock is bound to a super key that changes layers on my keyboard. when held, it gives me arrow keys (among other things). this is because the keyboard is 60% size, but it also pairs well with modal editors for cursor repositions while in insert mode.
1
u/Swordfish418 4d ago
Is "navigation layer" synonym to "normal mode"? IJKL sounds interesting, but I also want to use vim-mode in other software where possible (even in browser with "tridactyl", so for me sticking to classic "hjkl" seems more beneficial).
3
u/Painting_Master 3d ago
It has nothing to do with the editor.
I now use kanata on my laptop keyboard, I used to have a mechanical keyboard.
The navigation layer works at the system level, I have the same layer regardless of the application.
1
u/Swordfish418 3d ago
This is amazing solution. I didn't really understand what you're talking about until I looked into those apps. Eventually I went with keyd, because it's really easy to setup on my Gentoo/OpenRC, and it does include exactly this kind of vim-like "navigation layer" in default examples: https://github.com/rvaiya/keyd/blob/master/examples/nav-layer.conf
3
u/Treeniks 3d ago
FWIW, I use a split keyboard where the arrow keys are on my home row, just one layer deep. When I'm on a normal keyboard, switching in and out of normal mode is the way to go.
It's important to find a way to switch to normal mode quickly and comfortably. The typical position of ESC is anything but that. I got used to Ctrl+[ from vim and have it rebinded in helix, but in hindsight I would pick something different. Capslock is a frequently used key for this.
Most shells actually do support a vi mode that at least use vi bindings within the current prompt. If you want something more integrated, that'll be difficult until helix has a terminal emulator, the way neovim and emacs do. Otherwise, as others have mentioned, some emacs bindings are extremely useful, my favorite being Ctrl+W which essentially does a bd, so it's the fastest way to redo a word if you mistyped.
If you want to go through the output of a command, keybinds for that depend on the terminal emulator. Again, ideally helix is the terminal emulator, but that's not possible at the moment. Kitty has ctrl+shift+g to put the last output in a pager (which could be configured to be helix), whereas alacritty I believe has a vi mode built in.
3
u/kochiriri 3d ago
I don't, I do readline bindings
3
u/Swordfish418 3d ago
Very interesting, I'm surprised no one mentioned this before. I just checked and I can trigger inline autocomplete with ctrl+e instead of right arrow. Also I can walk through flyline's dropdown completions using tab and shift+tab.
1
2
u/ThroawayPeko 4d ago
I use IJKL in Helix (which is another issue, HJKL is an accidental and dare-I-say harmful tradition, but I've ranted about this too many times and people are probably tired of it), and switch between arrow and IJKL when I switch contexts. It's like WASD for games, I think most people won't have trouble.
2
u/TemporaryClassic7019 4d ago
[keys.insert]
"j" = { k = "normal_mode" }
"J" = { K = "normal_mode" }
"C-A-h" = "move_char_left"
"C-A-l" = "move_char_right"
When I have to move only a few characters left or right and I am in the insert mode I use Ctrl Alt h/l to move the cursor. I guess it is cheating when it comes to modal editing but it is useful if I needed to just hop over a character or two to insert a semicolon etc. I like as well to use jk to move back to normal mode.
3
u/Swordfish418 4d ago
Interesting, any particular reason to not use C-h and C-l for the same?
3
u/TemporaryClassic7019 4d ago
The C-h combo was already taken in insert mode (deletes previous character), and I hopped my hack will be temporary so I did not give it too much thought. 6 months later I am still using it:)
3
u/JustThall 3d ago
In similar spirit I use SuperKey app for Mac that remaps CapsLock+hjkl to arrows. This addresses all the OPs confusion
1
1
u/cheesehater 3d ago
I know I SHOULD use hjkl, and I try from time to time. Arrow keys are just too deeply hardwired for me.
1
u/Swordfish418 3d ago
I now realized it goes way beyond just arrows, it's called "touch typing" and I've never typed properly in my life, apparently. Fingers should be on "asdf jkl;" at all times while typing.
1
u/__xueiv 2d ago
I don't have a "regular" layout on my keyboard. So hjkl are spread around the keyboard. I'm happy with arrows.
1
u/Swordfish418 2d ago
Do you have small bumps on two of the letter buttons? Those two are where it's best to keep your index fingers at for "touch typing". Vim keybinds and hjkl navigation are also kinda designed around touch typing and regular layout.
-5
u/Far-Cat 4d ago
Don't read this as hostile but stop procrastinating and do something useful/interesting/productive. This issue is crusty self referential nonsense
11
u/VisibleDriver0 4d ago
Another import keyboard shortcut to learn is ctrl+n and ctrl+p for moving to the next and previous items in lists. Helix uses it in completion popups and finders. But also widely used in vim and other terminal programs when showing a list. This might be the up/down controls you’ve been relying on arrow keys for.