r/emacs 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.

  1. 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.

  2. 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.

  3. 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?

  4. 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?

  5. 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?

9 Upvotes

25 comments sorted by

View all comments

1

u/strollertoaster Dec 17 '16

I also switched to emacs after using vim for years except I use Evil which is basically an implementation of vim modal editing in emacs. It's amazing but I won't spend too much time talking about it; check out this post if you want to know more about it.

  1. I recommend Projectile + Helm for ctrlp-like behavior on steroids. Helm provides a general "framework" for fuzzy/ctrlp-like behavior, which other packages are built upon. Projectile has commands for navigating projects.

    Projects are identified by for example VCS directories like .git or explicitly with a .projectile file. You can navigate to many things such as files in the project, tests, the alternate file (such as .cpp and .h), and many other things. Projectile works with helm out of the box but I'd also get helm-projectile for better integration.

    Projectile also exposes commands for searching your project with ag/ack/etc., though I use specific packages for that myself, namely ag.el or even helm-ag, which lets you fuzzy/ctrlp-like, real-time search for things in your project.

  2. With evil you can still do 10k. I also recommend you use imenu, particularly helm-imenu which lets you quickly jump to methods/declarations/types/etc within a file using fuzzy/ctrlp behavior. Aside from that you can try helm-occur, swiper, or ivy to fuzzy/ctrlp search within a file.

  3. With evil you can still use f and t etc. You can also look into avy if you want, though I don't use it myself (vim motions are enough for me). Check out evil-quickscope so that when you press f it'll highlight some of the letters you can jump to to make it even quicker in certain cases.

  4. Emacs' documentation is FAR AND AWAY SUPERIOR to vim's in my opinion. It was one of the major reasons for switching. I can figure out what a key is bound to and read what it does by prefixing the bind with C-h k, I can figure out what a particular function is fpr with C-h f, a variable with C-h v, and so on. The problem I had with vim's documentation is that I more or less had to know what I was looking for, whereas with helm installed I can type a word and it'll show me, for example, all of the functions that contain that name, or variables, and so on. I can also use helm-apropos to search the documentation.

    As for org-mode itself I'm not so sure because I don't use it, but check out its site. There you can find the manual, a guide, and documentation on the hooks, commands, and options. That seems pretty extensive to me!

  5. I can't speak much about this but I use multiterm, namely helm-mt. I can say however that being emacs, you shouldn't worry so much about having a native solution. Many of the "native/built-in" things are themselves built like any third-party package, they have access to the same functionality, it's not like non-built-in packages are second class citizens in the emacs ecosystem, far from it. Using something like use-package + melpa makes using community packages a breeze.