2

I would like to know if there is an easy way for me to jump to specific folders when specifying paths in the minibuffer.

For example, when I do find-file and my current directory is in ~ and I want to go to /mnt/c/development/downloads. Instead of typing the whole path, maybe I could just type downloads and it would automatically complete the whole path for me.

With this kind of system, I could just specify directories somewhere downloads="/mnt/c/development/downloads", dropbox="/mnt/c/Dropbox", etc, and I only need to type the specific alias to quickly jump to them.

I'm open to any suggestions. It does not have to be exactly how I describe, I'm pretty flexible as long as I can be able to jump quickly from one directory to another.

3

There are several things you could do.

  1. Use pattern matching that abbreviates parts of the directory hierarchy or file name. Even vanilla Emacs lets you do this to some extent (e.g. with wildcard * and using hyphens (-).

  2. Use more powerful pattern matching, with a library such as Icicles or (I assume) Helm -- in particular, matching directory components to find a file anywhere.

  3. Use Emacs bookmarks to places (e.g., directories, files) you visit often, giving them names you want to easily match (using completion). See the Emacs manual, node Bookmarks.

  4. Define specific commands that either visit a single directory or file that you frequent or that complete against only a small number of such, with easily distinguished inputs (e.g. different single letters). In the first case, bind specific keys to specific file/dir visits.

There are many ways to help with your question. Others will no doubt fill in the list.

0

@Drew already gave several excellent suggestions. One more he didn't mention is that you can use environment variables from within find-file. You can set environment variables from within the comfort of Emacs, so if you evaluate (setenv "FAV" "~/my/favorite/directory"), then later from find-file you can type "$FAV" to switch to that directory.

Notice that when you use the environment variable, you don't need to erase the path you have, since a path like ~/first/this/~/then that is equivalent to ~/then/that. Also, you will have completion for environment variable names, so might not even need to type all of $FAV.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.