Skip to main content

Questions tagged [files]

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.

Filter by
Sorted by
Tagged with
46 votes
2 answers
10k views

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, ...
Dan's user avatar
  • 33.2k
97 votes
5 answers
35k views

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 ...
smonff's user avatar
  • 1,589
3 votes
1 answer
816 views

Open recent files buffer (recentf-mode) filled with autoload.el files

I've a problem with recentf-mode buffer in emacs. Apart from the files I opened before, its also showing all the autoload files for various packages I've installed which is cluttering the Open recent ...
Chakravarthy Raghunandan's user avatar
21 votes
2 answers
9k views

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. ...
Keks Dose's user avatar
  • 528
16 votes
4 answers
2k views

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, ...
wvxvw's user avatar
  • 11.4k
5 votes
1 answer
1k views

Character encoding when copying some text from somewhere to Emacs and saving to a file

Suppose I copy some text from a source (e.g. a webpage, a text file opened in an editor such as gedit or emacs) to a buffer in emacs, and then save the buffer to a text file. When I copy the text ...
Tim's user avatar
  • 5,027
4 votes
2 answers
4k views

Setting default-directory does not change find-file directory

I try to set a default path for opening a file via C-x C-f by adding the following to my .emacs: (setq default-directory "~/some_dir/") However, after I launch Emacs in some directory, the find-file ...
MLister's user avatar
  • 215
176 votes
10 answers
117k views

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's user avatar
20 votes
2 answers
12k views

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 ...
SiXoS's user avatar
  • 303
15 votes
5 answers
4k views

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 ...
Claudio's user avatar
  • 151
15 votes
2 answers
2k views

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 (...
mbork's user avatar
  • 1,687
11 votes
2 answers
810 views

Programmatically insert files into Dired buffer

I have a list of file names (with full path) and I want to create a Dired buffer listing this set of files. How would I go about doing that? How do I create a Dired buffer from a list of file names? ...
Tu Do's user avatar
  • 6,862
8 votes
2 answers
2k views

Saving open file list and buffer command history in between sessions

I've discovered desktop-save-mode which allows Emacs to be closed and when it reopens, it appears with the same files that were open before. I want to take this a bit further and I was wondering if I ...
Galder Zamarreño's user avatar
17 votes
9 answers
9k views

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 ...
Evan Aad's user avatar
  • 1,551
16 votes
6 answers
7k views

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/ ./...
Rafa de Castro's user avatar
14 votes
1 answer
5k views

Open file in new window after searching it with helm

As written in A Package in a league of its own: Helm there's a way to search for a file using Helm decide after searching whether open it in same or other window My question is: How?
Empty_Mind's user avatar
  • 1,371
14 votes
5 answers
9k views

What is the easiest way to open the folder containing the current file by the default explorer of the OS?

What is the easiest way to open the folder containing the current file by the default explorer of the OS (e.g. explorer.exe in the case of Windows OS)?
Name's user avatar
  • 7,935
13 votes
4 answers
18k views

Spacemacs: kill buffer and kill window in one command?

Is there a spacemacs command that both closes the window and kills the buffer? In other words, the equivalent of Vim's :q?
sid-kap's user avatar
  • 544
13 votes
5 answers
9k views

Comparing two text files on a Windows system

Since ediff-files and ediff-buffers result in apply: Searching for program: no such file or directory, diff error on windows machines. How to compare two files using Emacs on a windows system?
Empty_Mind's user avatar
  • 1,371
9 votes
2 answers
2k views

.tramp_history files

I have noticed that opening a tramp connection on remote hosts sometimes created a .tramp_history file in the user's directory. Is there any way to disable such a behavior? I have to log in to many ...
KookieMonster's user avatar
9 votes
2 answers
1k views

How can I jump to a file and line number from a list in a buffer?

I have a buffer with content like: src/file4.rs:9 src/file4.rs:33 src/file4.rs:64 I'd like to be able to put my cursor on a line and jump to the appropriate file / line in the other window, just ...
Shepmaster's user avatar
8 votes
1 answer
1k views

Specify major-mode for files with multiple extensions

In my .emacs file, I have: (setq-default major-mode (lambda () (let ((buffer-file-name (replace-regexp-in-string "\\.tmp$" "" ...
Nathaniel Flath's user avatar
6 votes
0 answers
274 views

Why is cloning of file buffers prohibited?

Why does clone-buffer not work on file buffers. I can make it work by the following advice: (advice-add 'clone-buffer :around (lambda (oldfun &rest args) "Allow cloning file buffers." ...
Tobias's user avatar
  • 33.4k
6 votes
1 answer
192 views

How do I include non-code resources as part of an Emacs package?

I have a project that wants to play a sound file. I'd like to distribute this project in MELPA. There are two issues I'm having with that. They're both part of the question "how do I use ...
zck's user avatar
  • 9,112
5 votes
2 answers
2k views

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

helm-find is Preconfigured ‘helm’ for the find shell command I need the same functionality with ivy/counsel.
fhdhsni's user avatar
  • 703
5 votes
2 answers
2k views

Get file name relative to projectile root

I am trying to write a little function to get the projectile relative path of a buffer. My idea is to delete the substring projectile-project-root from the string buffer-file-name. For example: root-...
rafaelleru's user avatar
5 votes
3 answers
1k views

Load all org files into buffers?

I've got a couple dozen org files that I'd like to have loaded at once. They're in a directory structure something like this: org/dev org/dev/python.org org/dev/emacs.org ... org/dev/ios org/dev/ios/...
h4labs's user avatar
  • 269
5 votes
3 answers
633 views

Switch buffer to the file path in current cursor position

My .emacs file contains multiple file names as, (load "~/.emacs.d/others/keymaps.el") (load "~/.emacs.d/others/py.el") (load "~/.emacs.d/others/web.el") Is there a way any library, gives way for me ...
Saravana's user avatar
  • 2,081
4 votes
1 answer
2k views

prelude-ivy: How to select and open multiple files

I have installed Ivy (along with Swiper and Counsel) as part of Prelude by doing a (require 'prelude-ivy) in my prelude-modules.el file. It seems to work, but I am not able to figure out how to do ...
Angelo's user avatar
  • 301
4 votes
2 answers
639 views

Backup saved buffers to Dropbox (or other specific directory)

Is it possible to customize Emacs so that whenever I save a file, Emacs also copies it to a specific folder? This directory could be, for instance, D:\my_backups or C:\Users\username\Dropbox\...
Name's user avatar
  • 7,935
3 votes
1 answer
3k views

Ignoring specific files in recentf-mode [duplicate]

I use company-statistics to sort completion candidates by previous completion choices. It works perfectly, except there is only tiny problem. The file ~/.emacs.d/company-statistics-cache.el pops up in ...
Chakravarthy Raghunandan's user avatar
2 votes
2 answers
152 views

Instruct Emacs never to open files of a certain type or size

In Emacs by default there is a large file warning threshold. I would prefer to instruct Emacs never to open files of a certain type or size. These are files I would prefer always to open in an ...
Edman's user avatar
  • 1,229
2 votes
0 answers
314 views

How to find/grep in Python virtualenv with projectile/helm easier?

How I can customize helm/projectile behaviour to find files and grep in $VIRTUALENV dir easier? Or maybe I can write some function(s) to find/grep in virtualenv of current project?
sivakov512's user avatar
2 votes
1 answer
160 views

What are the '.#' links for? [duplicate]

When an Emacs buffer is modified, a broken link is created. The link's name is a concatenation of '.#' followed by the file's name. For example: $ ls .#spacemacs_ref.org -l lrwxrwxrwx. 1 wolfv wolfv ...
wolfv's user avatar
  • 1,403
2 votes
3 answers
332 views

call write-file interactively with prompting

I have a function that creates a buffer, with a default file name, and would like the first user action for that buffer be a prompt to write the buffer to a file, allowing the user to change the ...
user1404316's user avatar
2 votes
2 answers
3k views

Add hook for specific files

I am looking to create some customized settings for a specific file. I think I want to add a hook for that file, or something that will create a few settings when that file loads. For example, I have ...
modulitos's user avatar
  • 2,492
1 vote
1 answer
139 views

Loading addition org files along with default scratch buffer

I do a lot of my programming in Haskell and Python. I've started maintaining a personal cheat-sheet for each of these languages for common constructs and tasks I often come across. Hence whenever I ...
smilingbuddha's user avatar
1 vote
6 answers
2k views

How to append contents of multiple files into one file?

Emacs 26.1, Windows 10, Dired+ How to append contents of multiple files in one folder into one file?
a_subscriber's user avatar
  • 4,174
0 votes
1 answer
39 views

How to prompt for a virtual buffer (recently killed file buffer) using Ido completion?

When ido-use-virtual-buffers is set to t, ido-switch-buffer shows, after the list of live buffers, a list of killed file buffers in chronological order, last killed first. Those are what Ido calls ...
Arch Stanton's user avatar
  • 1,707