HACKER Q&A
📣 skwee357

I don't know text editing shortcuts. Should I learn Vim/Emacs/My IDE?


I live most of the time inside JetBrains IDEs. I occasionally edit random files, mainly in terminal using Vim. I also write a blog (with different tools, mainly Obsidian and Typora). In Firefox and Chrome, I use Vimium for years.

Recently, I've realized that I don't really master any editing shortcuts. I'm able to navigate char by char, word by word, end and beginning of the line, as well as selecting text. But nothing more complex.

For any complex file editing, I resort to mouse. I know that JetBrains have tons of shortcuts to help with text editing, Vim has its own as well as Emacs.

Few years ago, I've switched to 60% keyboard (so my arrow keys are on CapsLock+ijkl) and I feel like my typing speed did increase. I'm looking to make a similar improvement in regards to text editing and I'm wondering what should I invest it.

I know that Emacs shortcuts are pretty much universally supported. You can get them in MacOS and JetBrains, you get the in the terminal, and obviously in Emacs (which I used 2 maybe 3 times in my life).

Vim gets more love (from what I see) compared to Emacs, and you can get IdeaVim or even terminal navigation with Vim.

And I feel like mastering JetBrains shortcuts will help with text editing, but only in JetBrains tools.

I'm leaning towards trying to master Vim, but wondering if Emacs might be more useful, since I also write non code related text and use mainly MacOS (which as far as I know, honors most Emacs shortcuts). Mastering JetBrains shortcuts feel the least appealing to me, since I can't transfer that knowledge to other programs.

What are your opinions?

Edit: just to clarify, I'm not looking to switch to 100% Vim/Emacs. I'm instead wondering, mastering which shortcuts, will yield the most benefits for my (code)writing skills. I'm not in the mood to setup vim for code editing, and very much happy with JetBrains tools.


  👤 aasasd Accepted Answer ✓
Vim sidesteps the whole ‘point the cursor and then type’ drudgery by inventing a whole separate approach to walking through text and tugging at various pieces of it. As a consequence or coincidence, basic keys of that approach are very easy on the fingers—it's worth trying just to see what it can be like. You already have some taste of it through the keyboard and Vimium, but imagine the entire workflow being like that. (I have to admit that I haven't gotten to that proficiency myself, basically out of laziness.)

Emacs' hotkeys are like airplane controls, in my imagination. There are lots of them, and they're way less composable than Vim's. And since letters are used for typing, all those keys use various modifiers and their combinations.

Meanwhile, outside of Emacs basically all its keys that you want to know are Ctrl-A and Ctrl-E. Plus Ctrl-W is mostly universally supported, including Vim iirc. I don't even think that these keys are from Emacs originally—maybe readline was before?

I use Emacs for the versatility and the sane scripting language, but in it I use Evil for the Vim keybindings. Plus the Doom configuration maps many functions to sequences of keys instead of hotkeys with modifiers, via the spacebar prefix/menu.

As for the IDE, you will sure want to learn the keys for jumping over the code structure—like going to definitions, hopping to particular functions, maybe a couple basic refactorings. Though IIRC Idea had the ‘shift shift’ thing—a launcher of all kinds of functionally via quick text commands, which makes both some hotkeys and most menus unnecessary, in the style of all-purpose launchers like Alfred.


👤 throw_away
Vim controls are a certain mode of thinking & no offense meant, but it sounds like you haven't delved too deeply into them. The complexities come when you start to recognize that there are motions and operators and that these can be composed. That you are thinking about arrows means you're not really at that level yet.

First step is to not use arrows any more, especially while in insert mode. Put this in your .vimrc (or jet brains equiv):

  inoremap  nop
  inoremap  nop
  inoremap  nop
  inoremap  nop
Insert mode arrows destroy vim brain.

Then, once rid of these broken "training"-wheels learn some of the more advanced motions and operators. https://vim-adventures.com is fun.

The emacs/readline shortcuts are nice in MacOS text fields and in the command line, but there are only a handful I use regularly (^A, ^E, ^K, ^U, ^L). I would use vim-bindings in the shell, but I haven't found a good way to indicate my current mode, so I get confused & don't like it.


👤 noud
I use the keyboard 99% of the time. Practicing short keys, until they become muscle memory, is a good skill to have. I use vim short keys. But learning emacs would be fine as well. I think it won't hurt to learn both short key bindings.

Some tips for using vim shortkeys:

* You can install the hardmode plugin of vim, https://vimawesome.com/plugin/hardmode. This will disable the arrow keys, page up/down, and hjkl. This way you can only use the "advanced" vim short keys.

* Vimium is a plugin for firefox and chrome which allows you to browse on the internet using (some of) the vim short keys.

* All insert-mode short keys of vim also work in most terminals. Few people realize the equivalents: ctrl+m <-> enter, ctrl+h <-> backspace, ctrl+i <-> tab, ctrl+[ <-> escape. Control can easily be hit with your left palm. These two things combined saves a significant part of moving your hands. Since I program between 6 to 10 hours a day, these small changes are the difference between RSI and no RSI.

Good luck!


👤 themodelplumber
Yes, it's worth it. Multiple-model (in this case multiple editor) learning has huge benefits.

I would specifically define different generic levels of mastery (for example by using examples of your common editing cases) and then start to chip away at the lower levels in each editor. Track your progress. Your studies will be more resilient to adaptation this way.

You may also be able to create bridging-shortcuts that you define in JetBrains and also set up in other editors, or vice versa. Or snippets, maybe you use Espanso in all three for example.

It's always worth diving into this. You already have the forward-looking planning and contingency mindset which you demonstrate for us in your post. Add the execution-experimentation-analysis mindset now. You'll get immediate benefits. The contingency side will still be there when you need it later. Otherwise by giving too much contingency attention too early you can get stuck in a foresee-withhold loop without making any progress or learning anything new.

Good luck and share your results when you can.


👤 andresgaitan
Vim keybindings are one of the safest investments available to people in tech. You find vim keybindings everywhere. For example, some days ago I installed a plugin to have vim keybindings in Libre Office Writer!!!

The only safest investment in tech is touch typing.


👤 brudgers
The easiest road is use what you know. I once had a boss who wrote letters in Lotus 123 (for DOS) instead of Wordperect.

If you regularly log into fresh *nix installs from the terminal that’s a plausible reason to learn Vim.

If you want to live in an editor, that’s a plausible reason to learn emacs…it supports just about every language, email, task management, git, etc.

Emacs key stroke support is more directly supported by other applications, probably because most applications don’t use modal keyboard input by default…don’t have vim like if this then that then that keyboard logic.


👤 przemub
In Jetbrains IDEs you have an official IdeaVim plugin which allows you to use Vim shortcuts there. It's awesome for productivity!

👤 acomjean
FWIW, Emacs keyboard short cuts ^a, ^e and others work on the bash (and other shells) command line. I use them a lot to move around the command line.

👤 yes_but_no
Most of the editors have "good enough" support to be convenient for Vim shortcuts, which makes it safe investment I think

👤 wara23arish
I’ve been using emacs for about two weeks now. I’ve configured it so it has IDE like features for golang coming from Intellij. Its a struggle at first but as time goes by it becomes fun just to use it.