Hot answers tagged

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,963
20 votes
Accepted

Open large files?

I suggest you use the vlf package. It handles opening larges files in chunks and is very performant, I use it regularly to open files ~2gb. In your config, require vlf-setup to have vlf ask you if ...
Jordon Biondo's user avatar
20 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.3k
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
  • 301
17 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
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
13 votes

Edit file with super-user rights

There are today many packages that solve this problem (as of 2018). Some of them are: sudo-edit, allows to switch editing rights on an already opened read-only file. Just M-x sudo and type a password ...
smonff's user avatar
  • 1,575
13 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.2k
12 votes
Accepted

How to do a simple write to file

Use with-temp-file; this is documented at M-: (info "(elisp) Writing to Files") (also available online). This takes a filename or path and a list of body forms. It creates a temporary buffer, then ...
db48x's user avatar
  • 16.8k
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
  • 21.9k
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
  • 693
10 votes

How do I reload a file in a buffer?

you can also enable global-auto-revert-mode as shown below (global-auto-revert-mode 1) this is helpful when you do a lot of checks of your js files with auto-fix mode enabled, like in jssc.
DmitrySemenov's user avatar
9 votes

How to do a simple write to file

f third-party library has f-write-text and some other file manipulation functions, such as f-exists? predicate: (f-write-text "some string" 'utf-8 "path/to/my/file.txt")
Mirzhan Irkegulov's user avatar
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
  • 412
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.4k
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

Setting default-directory does not change find-file directory

According to the documentation: default-directory is a variable defined in ‘C source code’. Its value is "~/" Local in buffer *scratch*; global value is nil Automatically becomes permanently ...
Nsukami _'s user avatar
  • 6,391
8 votes

Why do some files generated by emacs have a tilde after their name?

These are backup files created by Emacs. See Backup in the Emacs Manual. The manual also says this: When Emacs makes a backup file, its name is normally constructed by appending ~ to the file name ...
Constantine's user avatar
  • 9,092
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,535
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.2k
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
  • 14k
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
  • 49.7k
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
  • 76.4k
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

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

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

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

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