Use this tag for questions about moving, deleting, or opening files. Or for questions about the difference between a buffer and its file. For topics such as "Saving Files", use "buffers" instead.
Questions tagged [files]
283 questions
169
votes
10 answers
How do I reload a file in a buffer?
I usually work on files which are updated in the file system via version control. What's a quick way to reload a file without having to C-x C-f the file again and getting asked if I want to reload it?

Fernando Briano
- 1,915
- 2
- 14
- 13
97
votes
5 answers
Edit file with super-user rights
When you have to edit system files, it's an usual situation that you launched Emacs with a normal user before, so the file will be write-protected. What can I do to gain root privileges? I mean something like M-x sudo from dired.
I don't want to…

smonff
- 1,575
- 1
- 15
- 20
44
votes
2 answers
What's the difference between a buffer, a file, a window, and a frame?
When posing questions on this site, people sometimes talk about "windows" when they mean "frames," and "buffers" or "files" when they mean "windows." So:
Q: What is the difference between a buffer, a file, a window, and a frame?
(I'm posing this…

Dan
- 32,584
- 6
- 98
- 168
20
votes
3 answers
How can I find the path to an executable with Emacs Lisp?
My current use case is to find where the Cask executable is (it can be installed in at least two places, and there's an issue open about this).
I need to require cask this way:
(require 'cask "~/.cask/cask.el")
But I need to find the correct path to…

Trevoke
- 2,375
- 21
- 34
20
votes
2 answers
Save current file with a slightly different name
My files have long filenames and a part of the filename is a date and a version number. Often I'd like to save the file in the buffer using nearly the same name, just change version number or date.
This would be much easier, if I had a command…

Keks Dose
- 508
- 4
- 19
20
votes
2 answers
Run command when opening a file of a specific filetype
I'm trying to get a lisp script to run some commands for me when I open a file of a specific filetype. I know that I'm working in the correct init file because if I remove the theme from it, emacs has no theme when I start it up.
This is the script…

SiXoS
- 303
- 1
- 2
- 5
17
votes
8 answers
Recursively list all files and sub-directories
Is there a way, possibly using a package, to recursively list all the files (with paths) and sub-directories (or at least the empty sub-directories, since the paths to the non-empty ones can be gleaned from the paths of the files contained therein)…

Evan Aad
- 1,461
- 1
- 14
- 29
16
votes
1 answer
How to prevent Emacs from breaking hard links?
Let's say I have two files file1 and file2:
$ echo aaa >file1
$ ln file1 file2
Then I check that the inodes are the same:
$ ls -i
18749779 file1 18749779 file2
which shows that the two files are actually the same. Now I edit file1 in Emacs, and…

Håkon Hægland
- 3,608
- 1
- 20
- 51
16
votes
6 answers
Ivy disable completion for a command in minibuffer
Can I disable ivy completion for a single command while in minibuffer?
For example I am in folder ~/code/study/ . If I open find file and autocomplete with Ivy I will see
Find file: ~/code/study/
./
../
[...]
and I want, in a single jump go to…

Rafa de Castro
- 1,231
- 10
- 14
15
votes
4 answers
Recursively open files matching regexp in marked directories
Generally speaking, I would like to be able to open all files within a given set of directories (and their subdirectories) where the filename matches a given regexp.
For example
/home/nispio/project:
total used in directory 1612 available…

nispio
- 8,175
- 2
- 35
- 73
15
votes
4 answers
How to tell Ido to get out of the way when I can already just paste the file name?
I'm trying to make myself use Ido mode. Some times it's nice, but other times it is extremely stupid. Here's my greatest disappointment.
I read some log with full file names, then I copy one name, try open that file.
The way to do this without Ido:…

wvxvw
- 11,222
- 2
- 30
- 55
15
votes
2 answers
What's wrong with `find-file-noselect`?
In a recent answer by lunaryorn, he stated:
However, I'd recommend against most other parts of Org, for reasons
already stated in comments: It's old, and full of legacy and harmful
practices (e.g. find-file-noselect to read files…

mbork
- 1,647
- 1
- 13
- 23
15
votes
2 answers
Display recursive folder sizes in-line in dired?
I'd like to display the recursive size (the value that would be reported by du) of folder contents in-line in the dired buffer as an additional column or in place of the directory file size. Is this already possible with dired/dired+ or a related…

ebpa
- 7,319
- 26
- 53
15
votes
3 answers
Put the current file name in the minibuffer
How can I insert the file name of the active file buffer into a command?
When I invoke a command that needs a file name, I am often doing so from a file buffer and want the name of that file while typing the command into the minibuffer.
I'm looking…

bignose
- 627
- 3
- 15
14
votes
5 answers
How do I search and replace over a set of files?
I'd like to define a set of files within which I can search and replace text.
To clarify:
I would like to be able to search, e.g., in all files xk*.tex in a given directory (and excluding backup files). I would also like to be able to change the…

Claudio
- 141
- 1
- 3