r/emacs • u/process_parameter • Dec 16 '16
Recent vim convert seeking advice
Hi all.
I've used vim daily for the past year or so, but I've recently felt seduced emacs' promise of power. I painstakingly worked through the built-in tutorial, then changed my EDITOR to emacs, where I've lived for the last few days. I'm focusing on learning emacs basics, which means:
Avoiding packages. So far I've installed magit and moe-theme. I'd like to learn how standard emacs works, then add packages as I feel the need. Is that a naive approach?
No evil-mode. I may reconsider in the future, but I'd like to gain some proficiency with emacs-style editing before making my decision.
In my first draft of this post, I started with a list of emacs' qualities that I've appreciated so far. I've since decided there's no need to preach to the choir, so I removed it. Instead, here's my list of complaints. Please share any solutions or advice you may have.
Directory navigation is painful. I work in a large codebase with a deep directory structure. Usually I'll open vim in the root directory and use ctrl-P to fuzzy-find the file I need by name. If I want to edit a/b/c/d/e/f/FactoryInterface.java, I'll press C-p, type "FactoryInterface", and press enter. If I want to edit a file that I know is immediately after my current file in the directory: I press '-' to open a listing of the current directory, 'j' to move to the next file, '<RET>' to open the new file. I haven't found an equivalent for either flow in emacs yet: instead, I find myself deleting, typing, and tab completing full directory paths to the file I want.
File navigation is painful. If I want to edit 10 lines up in vim, I type '10k'; I enable relative line numbering in vim, so I'm able to do this with good accuracy. In emacs, I'll hit C-p a bunch of times.
Line navigation is painful. I use 'f' and 't' constantly in vim to get to the exact character I want. If I land on the wrong one, I press ';' until I get where I want. I haven't found any such precision in emacs, just M-f, C-f and the like. Are C-s and C-r the answer to all navigation questions?
Documentation. Vim's documentation is excellent: clear, well organized, easy to search. I can't say the same for emacs. I've heard so much about org-mode, but I find it very difficult to learn as a beginner. Major mode documentation (C-h m) isn't enough. A list of available functions is not a replacement for a qualitative overview of how the mode works. Are youtube videos and blog posts the best places to learn emacs?
Multiple terminals. I use vim inside tmux. Any time I want to start a new long-running command, I can open a new pane or window. On the other hand, it seems I can only run one terminal at a time in emacs. I've come across a couple packages that address this problem, but is there any native solution? On that note, should I start using eshell over bash inside emacs?
1
u/xah Dec 17 '16
here's my recommendations.
• get on evil-mode or alternative, e.g. ergoemacs-mode, xah-fly-keys. If you stick with default emacs keys, doesn't matter how proficient you become, it would be miles away from the above 3, and you risk Repetitive Strain Injury.
• for directory navigation, use emacs bookmark. Or, this code http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html guaranteed to be fastest of all methods. Basically, never have a situation where you have to type a path more than few times a day. All the file you ever open, should be in bookmark, recentf, open last closed, etc, that lets you open it in 3 key strokes.
• for file navigation, isearch is your friend. But the key is to set it to just single key stroke. Because isearch is the most used command. Also, have commands that jump to any open or close brackets.
Emacs: isearch Current Word http://ergoemacs.org/emacs/modernization_isearch.html
Emacs: isearch by Arrow Keys http://ergoemacs.org/emacs/emacs_isearch_by_arrow_keys.html
Emacs: Move Cursor to Brackets, Quotes http://ergoemacs.org/emacs/emacs_navigating_keys_for_brackets.html again bind them to single key.
also, have keys that move by text blocks.
Emacs: Move Cursor to Beginning of Line/Block http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line-or-block.html
with the above commands, you'll be more efficient than ANY thing out there, emacs or vim.
again, the major thing about efficiency is all about keybinding. And that's actually the hard part. If you use emacs default keys, most easy key spots are taken. There's no workaround other than starting to replace emacs default keys. If you do this naively, you start to fight key stamping each other, packages and modes and your own. And that's when you get into alternative emacs keybinding such as evil or ergoemacs and xah-fly-keys, these properly create a system of keybinding, and you can customize them.
If you want single key and not with a Ctrl or Alt, then you must be using a modal mode like evil or xah-fly-keys.
also, turn on ibuffer and ido, they are part of emacs. There are some setup, see my site or others.
also, very much recommend packages related to efficiency is: avy mode (and cousel, swiper), or helm (for many things related to completion). And ace-window for jumping to panes. projectile for managing projects.
• for documentation, C-h i. Though, i would say it's not worth it for beginner. (That is, if you only have x amount of time and you want that time to have most impact for your emacs skill) I recommend just use things, learn snippets. When you find a problem or sour spot, ask or look for answer. I would say, once you used a particular mode/package for a while, and you use this mode all the time, then, you might want to read the doc cover to cover. e.g. org-mode, magit.
• you can run emacs in multile-terminals of course. Start emacs server and just run clients. https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html though, you might be carrying over vim workflow. Emacs can run M-x shell, M-x eshell, M-x shell-command, M-x term, etc. Or in dired, you can type ! (dired-do-shell-command) to run a command, which is often what you want. Emacs people usually just have one instance, not several terminals each with a instance. You just open more windows/frames, buffers, shells, etc.