by rmunn · 1mo ago · 0 comments
If you're a diehard modal-editing aficionado like me and think that Emacs is a great IDE but it's a shame about its editor (and its keyboard scheme), maybe give neorg a try. Might well make you shift away from notes.txt files.
And yes, I know I could just use `evil` in Emacs. Maybe someday I'll overcome my decades of learned resistance to running Emacs, but every time I see the Emacs control scheme, I wince and I'm reminded why I don't use it. Having some key combos be "hold down the Control key while you press two keys" (like `C-x C-s` to save a file) while other key combos are "hold down the Control key while you press one key, then release it before pressing the second key" (like `C-x s` to save all files) is just not going to fit into my brain. Maybe that's intuitive for some people, but it just doesn't work for me. And so I bounce off Emacs before ever giving it a real chance.
For example - let's put "go all the way to the right" on the left button. And "go all the way to the left on the combo of modifier with right button". I'm talking about 0 and $ (Shift+4) for vi. It's not consistent, it's not ergonomic or easy to input when properly touch typing. It's almost an accidental control scheme because it was based on no longer existing keyboard keycap labels. And in this case where you can't even exit vi without first reading a manual, half an hour reduction in learning time that you get from remembering that `i` is Insert will not compensate for hundreds or thousands hours using later when you will be pressing button not by looking at keyboard but by muscle memory.
Yeah, if keyboard positioning matters to your brain then you're going to be really annoyed by 0, a key far to the right, meaning go to the left. But the only vi keystrokes that are assigned by keyboard position rather than meaning are the h/j/k/l navigation keys. Everything else has a meaning-based mnemonic, and until I read your post I hadn't ever thought about their position. I want to press 0, my touch-typing class from my teenage years has drilled that key's location into my hindbrain, so my fingers reach up and press it without thinking about its location at all. The only thing that went through my concious mind was "I want to go to column 0" and then boom, I had typed it.
My point is that position is the primary thing that's important for an editor when used for a long time. Your hands and fingers move in physical space, not over alphabet. They get tired and maybe get repetitive strain injuries over real movement.
Mnemomics way of setting up keyboard layout (or rather typewriter) would be to put everything in alphabet order. But we quickly realized that it's not a good way. `d` is where it is because according to (imperfect) research it's a common letter and so in QWERTY layout this letter should be on your home row.
Putting A-something on `a` because the word starts with `a` is not a long term design. Considerations should be based on usage. How often is this used? Put it closer to home row. Is it designed to be often used with another command? If often, those two probably shouldn't be on single finger. And so on.
There is argument for easier start - except that I said already - modal editors are unusable without reading docs first, so that argument doesn't really hold.
It’s a modal editor, so the basic vi/vim motions are of course there almost by necessity, but then it does a drastic shift to actions that were indeed engineered and thought-through intentionally, instead of being made up long ago and then accepted as gospel (love the analogy, by the way).
It’s now my favorite editor by far (not just because of how you use it to shuffle text around, but that is a big part of it), and has solved many of the gripes I had had with trying not to learn the basics, but getting really “at home” with standard vi/vim/neovim controls.
Your example would be <g-h> and <g-l> instead of 0 and $, which I find highly intuitive: Reuse the known left/right motion for a character, and prepend it with a “goto” to signify the whole line.
[0] https://helix-editor.com, also see default keymap: https://docs.helix-editor.com/keymap.html
jkl; would get you movement over home row without moving hand/fingers at all. ijkl would get you movement without involving pinky and some people like that.
If you have (and I do) column-staggered ergonomic keyboard - meaning columns are shifted according for length of your fingers - hjkl makes you move fingers to columns that are slightly off.
I don't see a single objective benefit for choosing hjkl on its own. Yet it's still there and I don't take "they did in vi" as valid for new editor. They could make alternative scheme for vi-comers, but as main idea again?
What you mentioned - g-h and g-l - are definitely more consistent than what vi did.
> I don't see a single objective benefit for choosing hjkl on its own.
“j looks like a down arrow” is easy to remember as a sort of anchor key :-)
0/$ doesn't matter when they're both one layer down.
But NeoVim has made writing plugins so much easier, even things like editing Lisp are getting not too bad. https://github.com/Olical/conjure has been a pretty decent substitute for SLIME, there's a paredit implementation that works well, and so on. So the need to switch is lower and lower, and the cost of switching stays high-ish, and so I haven't done it yet. Someday, as I said, I'll give it a shot.
P.S. I would be remiss in recommending LazyVim if I didn't at least once mention the really, really good https://lazyvim-ambitious-devs.phillips.codes/ book, which you can read online entirely for free. It's an excellent resource to learn LazyVim and what it adds to a vanilla NeoVim installation.
Conjure looks great but IMO it's not a 1:1 substitute for tight coupling between editor functionality and internal tooling. If neovim gets 80% of the way to a productive coding setup then emacs helps hone that last 20%.
> Do you have any examples of these Emacs shortcuts that simplify your life?
> I tried using Emacs with Evil but I was just using it as a somewhat laggier Vim.
Learning how to use prefix arguments and writing interactive functions have been very useful. Whenever I want functionality that's just a little different than what Emacs provides, I can always write a function and bind it.
Emacs also comes with regional undo/redo and has great undo tree visualization plugins.
Another feature I've come to appreciate recently is the built-in per-frame and per-window tabs. I moved from using separate frames to using tabs. Tabs inside tabs lets you visit many files at once while keeping visual clutter to a minimum. (In Emacs parlance, a "frame" is the window your WM handles, and a "window" is a visible child of that frame)
Also, outline-minor-mode is really nice for annotating files with headings. You can define custom regexp and sidestep collaboration restrictions and quirky formatting.
The calc is super-useful.
file-local variables are useful. directory-local variables are incredible, they set up custom environments for all folders at the same level / below them. Imagine doing a (let) but over a directory structure.
Vim has default C-p completion. Emacs has hippy-expand, which IMO is better. Some glue around hippie-expand can also make it work with a drop-down completion interface like corfu.
Some examples:
In tab-bar-mode the tab nav functions don't wrap around. So I wrote a small wrapper around the tab nav functions. It's about 10 lines of elisp and handles forward, backward and tab creation. For neovim this would've been much more difficult. In emacs it involves basic functions: interactive, let and cond.
I have a small package that opens new scratch buffers and inherits the major-mode of the buffer it was invoked from. Very useful to write temporary code. One shortcut and it always works.
I have a function that opens all dired selected files in a new tab/frame. Great for organization. Basically you open dired, mark files and run the commands, and they're open in a new tab, and all marks are unmarked. So you can very quickly structure a project for work.
Another function that moves forward/backward to the next logical file. Saves me a trip to find-file / dired.
I have a monorepo that I code in and it has different folders for different languages / folders. Because it's a monorepo, file completion shows ALL files in the monorepo. And running a LSP server also starts at the monorepo root, which is not ideal. With directory-local variables, I can set a custom file (like .gitignore) to denote a repo root. So emacs (and LSP servers via Eglot) will consider the presence of that file the repo root and make it work like an independent repo. ((nil . ((project-vc-extra-root-markers . (".gitignore")))))
(I've been using Emacs longer than I used vim, so my experience is skewed. I also used it as a laggy vim (Doom Emacs) for the first few years, and then moved to a custom config, which helped me really understand what was happening under the hood)
Perhaps there is a vim plugin for each one of these; but I certainly wouldn't be able to do ALL of these by myself in vim! Also because many of these are built-in emacs functions, they're guaranteed to be supported for a very long time.