Skip to main content
Share Your Experience: Take the 2024 Developer Survey
31 votes

Ivy disable completion for a command in minibuffer

I think what you're looking for is C-M-j (ivy-immediate-done) in the mini buffer. This function is described as follows in the Ivy manual: Exits with the current input instead of the current ...
tirocinium's user avatar
22 votes
Accepted

How can I find the path to an executable with Emacs Lisp?

@Sigma's answer is a good start, but it doesn't filter by executability, nor does it allow for extra suffixes. On windows, for example, running a can invoke a.exe, if that's what's in your path. So ...
Clément's user avatar
  • 3,995
21 votes

Recursively list all files and sub-directories

directory-files-recursively (I think this was added in Emacs 25) here's the link to the manual: https://www.gnu.org/software/emacs/manual/html_node/elisp/Contents-of-Directories.html Return all ...
wvxvw's user avatar
  • 11.4k
18 votes

Open file in new window after searching it with helm

I'm using Spacemacs (on Windows 10 if that matters) with the default keybindings. This may differ from your configuration, but I found the following ways to open files via Helm-Find-Files: Open Helm-...
Jason Down's user avatar
18 votes

Spacemacs: kill buffer and kill window in one command?

spacemacs binding for kill-buffer-and-window: Cx,4,0
sjas's user avatar
  • 311
15 votes
Accepted

how to ignore current selection from ivy when my typed text matches one

C-M-j (ivy-immediate-done) - exit with the current action, calling it on the current input instead of the current candidate. This is useful especially when creating new files or directories - often ...
Adrian Staniec's user avatar
15 votes

How to prevent creating files starting with .# (lock files)?

How I can prevent generating the lock file .#rest.api.rc? Set the user option create-lockfiles to nil, but note that this can stop Emacs from being able to detect simultaneous edits to the same file. ...
Basil's user avatar
  • 12.4k
11 votes

Can I view within Emacs the properties of a file which I already opened?

There doesn't seem to be a command to get this info interactively, although you can use dired as @jrm suggests. You can get this information with the following elisp code: (file-attributes (buffer-...
Tyler's user avatar
  • 22.3k
11 votes
Accepted

Recursively list all files and sub-directories

Assuming you use ivy you can use this function (defun fhd/counsel-everything () "list everything recursively" (interactive) (let* ((cands (split-string (...
fhdhsni's user avatar
  • 703
9 votes
Accepted

Can I view within Emacs the properties of a file which I already opened?

Here is a command that uses dired with verbose file flags for the ls command. You may want to customize those flags depending on your operating system. (defun file-info () (interactive) (let ((...
jrm's user avatar
  • 422
9 votes
Accepted

Ignoring specific files in recentf-mode

(add-to-list 'recentf-exclude "company-statistics-cache.el") or more accurately (add-to-list 'recentf-exclude (recentf-expand-file-name "~/.emacs.d/company-statistics-...
xuchunyang's user avatar
  • 14.6k
9 votes
Accepted

Spacemacs: kill buffer and kill window in one command?

Spacemacs has recently added two shortcuts for kill-buffer-and-window: SPC b x and SPC w x.
sid-kap's user avatar
  • 544
8 votes
Accepted

Display recursive folder sizes in-line in dired?

Indeed, Alex is right. If your Emacs version is >=24.4, then you can try `dired-du' library. It's available from the ELPA repository. Once you've installed this lib: If your current buffer is in ...
Tino's user avatar
  • 420
8 votes

Spacemacs: kill buffer and kill window in one command?

Use kill-buffer-and-window to close a buffer and its window. But this will keep emacs running. If you also want to kill emacs (the equivalent of :q) then try evil-quit-all if you're using evil, and ...
mclear's user avatar
  • 1,555
8 votes

What's the equivalent of `helm-find` in ivy/counsel? I want to find files **recursively**

The counsel equivalent of helm-find is counsel-file-jump. See also counsel-dired-jump and John Kitchin's answer for suggestions on writing a custom function.
Basil's user avatar
  • 12.4k
8 votes

Ivy disable completion for a command in minibuffer

There are multiple approaches to file navigation that apply here. Just to rephrase your statement: switch from ~/code/study to ~/other/code/study Easiest and most consistent: use ~ to switch to ~/...
abo-abo's user avatar
  • 14.1k
8 votes
Accepted

Why does calling expand-file-name indirectly produce a different result?

In short: dynamic binding. It is maybe a little unfortunate that default-directory was used as the argument to expand-file-name. Note the docstring: (expand-file-name NAME &optional DEFAULT-...
phils's user avatar
  • 51.5k
8 votes

Dired: How to find all files under a directory that match a glob pattern (wildcards)?

Use command find-name-dired. M-x find-name-dired RET my-directory RET *.txt That opens Dired to a listing of all files matching glob pattern *.txt in and under directory my-directory. The usual ...
Drew's user avatar
  • 77.9k
7 votes
Accepted

How to delete all instances of a character in a bunch of files?

Unless you want an interactive confirmation, which you presumably don't since you're automatic the replacement of all occurrences, call replace-string or replace-regexp instead of query-replace-string ...
Gilles 'SO- stop being evil''s user avatar
7 votes

How to split a long org file into separate org files?

I use a function of my own. It moves a subtree to a new org file, and replaces it with a link to this new file. Specify the name of the file through the parameter or interactively at the prompt. (...
tbanel's user avatar
  • 541
7 votes

How do I reload a file in a buffer?

For spacemacs users: SPC b R (spacemacs/safe-revert-buffer). For skipping confirmation, other answers already cover that, though I agree with others that it's probably not a good idea to bind that to ...
Croad Langshan's user avatar
7 votes

Comparing two text files on a Windows system

If you have git for windows installed, then it is enough to add C:\Program Files\Git\usr\bin\ to your PATH, because it already ships with a diff executable and installs it in that folder.
FlyingFoX's user avatar
  • 181
7 votes

Edit file with super-user rights

If you use Helm. You don't need any external package / additional config. it works out of the box. Inside helm-find-files you can invoke find file as root which bound to C-c r. This works for files ...
azzamsa's user avatar
  • 634
7 votes
Accepted

Count number of files with specific extension on a folder?

(length (directory-files "~/Pictures" nil "\\.png\\'")) See C-hf directory-files
phils's user avatar
  • 51.5k
7 votes
Accepted

How to make emacs automatically kill buffer after invoking delete-file command?

I wrote this method, which differs slightly from the one in the other answer: (defun delete-file-visited-by-buffer (buffername) "Delete the file visited by the buffer named BUFFERNAME." (...
zck's user avatar
  • 9,102
7 votes
Accepted

Single function to return file contents as a string

There is not. You can report-emacs-bug and suggest that one be included. One reason I can think of for not including such a function is that there are different reasonable ways to handle errors. E.g. ...
Tianxiang Xiong's user avatar
7 votes

Get file name relative to projectile root

I think the reason your code is not working as hoped for is because you are using the buffer-local variable projectile-project-root instead of the eponymous function. C-hvprojectile-project-rootRET ...
Basil's user avatar
  • 12.4k
7 votes
Accepted

Open directory containing file during counsel-file-jump

You can create a new Ivy action that opens the directory of a file name selection. It can be done with: (defun my/ivy-open-dir-action (x) (interactive) (dired (or (file-name-directory x) ...
Wanderley Guimarães's user avatar
7 votes
Accepted

Why Emacs (dired+) asks me twice to delete file?

So when you open a file it creates a 'buffer' with the file's contents. The first yes moves the physical file to the trash. But the 'buffer' is still loaded in Emacs. If you say no to the second ...
Greth's user avatar
  • 355

Only top scored, non community-wiki answers of a minimum length are eligible