Questions tagged [find-file]

is the most frequently used command for opening files in Emacs.

Filter by
Sorted by
Tagged with
43
votes
5answers
9k views

How to use an external program as the default way to open PDFs from Emacs?

When I M-x find-file a PDF, it is opened in Emacs. While this is nice, Emacs' PDF viewer lacks many features that I need and I would prefer to open PDFs in an external program instead. How can I ...
12
votes
5answers
2k views

Recently opened files in ido-mode

I use ido-mode, but one thing I hate about it is that after C-x C-f I cannot use up/down keys to cycle through recently opened files, as it used to be for example with iswitchb. How can I set ido to ...
5
votes
3answers
716 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/...
5
votes
3answers
546 views

When using C-x C-f turn off the suggestions

When i do C-x C-f to create a new file in the directory A, if emacs finds another file in another directory (say B) with exact same name, in the mini-buffer it changes the path to the other existing ...
4
votes
4answers
422 views

Find file in directory

I switched to Org Mode and Emacs few weeks ago. I find it incredibly better than my previous (simple but effective) setup based on markdown files and VS Code editor. I'm learning new features ...
4
votes
2answers
626 views

Is there a way to show/open a file from a URI/URL

Is there some way to download and show a file from a URI/URL? I now I can use wget and then open the downloaded file and I guess I could even try to write myself a small function to do this. But ...
4
votes
3answers
691 views

Quickly open file by full path in clipboard

There is something that blocks my workflow quite often and I'm quite sure it's easy to solve. I sometimes copy file paths (e.g. /tmp/bar/foo.gz) from the command line into my host systems clipboard. ...
4
votes
3answers
333 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 ...
4
votes
1answer
122 views

Open directory containing file during counsel-file-jump

I use counsel-file-jump to search files recursively. I would like to open the directory that contains a particular file candidate. I can execute counsel-dired after I open the file, which allows me to ...
4
votes
2answers
849 views

Template for new file

When opening a new file of certain types, I would like some boilerplate to be inserted. That is, when opening a buffer for a file that does not yet exist, insert some predefined text, optionally with ...
4
votes
1answer
201 views

How to check, if a file is already visited?

I have the following code, which opens a file, inserts some text, saves the file and closes it. (defun batch (file) (find-file file) (end-of-buffer) (insert "nix") (save-buffer) (kill-...
4
votes
2answers
69 views

How to pipe large files through fold before opening?

On a regular basis I need to open files that have really long lines, which unfortunately causes emacs to grind to a halt. My understanding is that this is a long-term issue with the renderer. I've ...
4
votes
1answer
559 views

How to set the coding system for new files with specific extensions

When I visit a new file, ^xf, that has an extension of .sql or .dsql I would like the coding system to be set to utf-8-with-signature-dos. The default is currently iso-latin-1-dos. I'm running (...
4
votes
3answers
456 views

Display path and filename in a minibuffer

Eval this code: (defun xx-display-filename (filename) "" (interactive "Ffilename: ") (message (concat "Filename is: " filename))) Let's assume that I am editing a ~/.emacs.d/personal/custom.el ...
4
votes
2answers
454 views

How to use find-file with wild-cards non-interactivley?

In this post it talks about opening org files via find-file. I'm trying to do this non-interactivley. I try calling: (find-file "~/git/LeoUfimtsev.github.io/org/" "*.org") But instead of opening ...
4
votes
2answers
241 views

find-file for file path with space in windows

In Windows, both find-file and helm-find-file don't work if there's space in the file name. For example: I move cursor to the anywhere in the string "c:/a/b.yaml", and then call find-file (C-x C-f), ...
4
votes
1answer
2k views

transparently find file over ssh in *shell* directory

I ssh'd into a remote server from shell and tried to open a file on a directory path that also exists on my local system. The list of files I was able to open using helm-find-files was the list on my ...
3
votes
3answers
3k views

Regex for any file not ends with

How to write a function for finding all files in a directory which not ending with pyc and pyo? I've tried something like (find-lisp-find-files root "^(?!.*pyc$).*$") but it does not return any ...
3
votes
3answers
192 views

Running out of L:/ etters: shortcut for path needed

I'm working with files which are stored on a server. The structure on the server is: //SBS/share/path/to/somewhere/2007/ //SBS/share/path/to/somewhere/2008/ //SBS/share/path/to/somewhere/2009/ ... //...
3
votes
2answers
2k 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 ...
3
votes
1answer
812 views

auto-insert a skeleton and run a function when creating a new file

auto-insert-alist by default matches files created in .../bin/ directories and enables sh-mode. There are examples on the wiki showing how to use a skeleton to insert some text, but I want to both ...
3
votes
3answers
437 views

How to create a keybinding to a file in Emacs?

I have a frequently opened file in Emacs, which is deep inside my device. I want to bind the F5 key(or any other key) to open that file, how can I do that? (Using android to run emacs. [GNURoot, ...
3
votes
1answer
229 views

Tell Dired to ignore file-at-point when invoking `ido-find-file` (`C-x C-f` in Ido mode)

I have discovered that a recent update to some of my emacs packages have caused C-x C-f while on a dired file to perform some operation on the entire file before prompting me for other files/...
3
votes
4answers
841 views

How show recent files?

windows 10, emacs 26.1 Suppose I open 10 files. And then restart Emacs. After restart I need to see what files (recent) I was open before. Is it possible to show some buffer that contain name of ...
3
votes
1answer
48 views

Force ffap to ignore '<' and '>' in file names

I am using find-file-at-point and it stubbornly selects incorrect file name string in NXML mode: String where I have cursor on the file name: <include>my-file.ext</include> and when ...
3
votes
2answers
560 views

Exclude dot-files from the find-file Completion List

When I run the find-file command and hit the tab key twice without giving anything, I get the Completion List of my, for instance, home directory. By default it lists everything inside, including the ...
3
votes
2answers
413 views

Set a global default directory

I want a "default directory" which is constant across all contexts (buffers, packages, etc). That is, when working on multiple files, opening a new terminal, doing anything which requires a starting ...
3
votes
2answers
171 views

Problem with save-current-buffer and find-file

I have a list of files that I want to successively visit with find-file and then return to the first buffer. I thought that save-current-buffer would help me to achieve this. However, with the ...
3
votes
1answer
235 views

`find-file-hook` problem for large buffer that is just one long line

I got a file(for instance, ~/.mozilla/firefox/xxx.default/sessionstore-backups/recovery.bak) that its content is one whole line and size of over 1MB, if I open it in Emacs, Emacs will become very ...
2
votes
5answers
787 views

Quick jump to a specific line of a file

After opening a .txt file with Emacs, when the point is at the line /folder/subfolder/file.xml:435 How can I fast jump to line 435 of the above mentioned file? What I tried: dired-at-point and ...
2
votes
3answers
2k views

How to find file name a few levels down in directory?

I am new to emacs (using Spacemacs with Evil and Ivy). This is how I open a file: SPC f f (counsel-find-file) Find file: I entered path of file. Ivy matches words one directory at a time. But ...
2
votes
1answer
128 views

Reloading files from disk in frame with emacsclient

This may be user error, but if I open a file with emacsclient -c file.tex then if I try to reload the file using C-x C-v, then I get the usual Find alternate file: but if I press enter on that, I ...
2
votes
1answer
187 views

Omit current and parent directories in Ivy find-file completion

I'm using Ivy in a fairly standard Spacemacs setup. When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates. In particular, I'd like to be able to tab through ...
2
votes
1answer
585 views

Can I stop Emacs from resetting default-directory every time I open a file?

If I: Start Emacs in my home directory (~) Find a file in the ~/Projects/ruby-play directory with C-x C-f Try to find another file with C-x C-f The default directory in the file finder will be ~/...
2
votes
1answer
185 views

Function to open all Org files in a folder recursively

I am looking for a way to open all Org (or Fountain) files in a folder using one function. Essentially, I am seeking to open all available files of a certain type (.org or .fountain) within a folder ...
2
votes
1answer
148 views

open files at last-edited position

What I want to achieve is this. I open a bunch of files, edit them and quit Emacs. then tomorrow I open one the files and I want Emacs to jump to the last edited position on that file. How can I ...
2
votes
4answers
100 views

How to find a directory with given depth from current directory?

Is it possible from within Emacs to find directories with a given depth from the current directory from within Emacs and receive their respective location in form of a list? I want it to work cross ...
2
votes
3answers
1k views

Is there a way to make emacs fully complete a filename and cycle through the completions by hitting tab?

In Windows (the command prompt) when you hit TAB to complete a file name, you get a full file name, and can cycle through the completions by hitting TAB. Is there any ready way to get emacs to do ...
2
votes
2answers
70 views

Aliases on minibuffer for quick switching of directories

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 ...
2
votes
2answers
72 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 ...
2
votes
1answer
52 views

Open folder `/ssh:example.com` or file in it

You can open SSH resources in Emacs. Unfortunately, the pathspec used for SSH resources conflicts with possible paths in the virtual file system. If I run sudo mkdir "/ssh:example.com" sudo touch "/...
2
votes
2answers
348 views

How to find a file recusively in children directories?

How to find a file recursively in children? Like the opposite of locate-dominating-file (locate-dominating-file finds file recursively in its parent directory)?
2
votes
1answer
198 views

Remapping find-file to helm-find-files

I have Helm installed and added this line to the end of the init file: (define-key global-map [remap find-file] 'helm-find-files) So, when I restart Emacs and try C-x C-f it executes helm-find-files....
2
votes
2answers
121 views

Looking for an existing function for find-file-not-found-functions to do form style creation

I have the habit when creating larger projects to make files called skeleton.typ with all the standard boilerplate for a file of that type (e.g. copyright notices, licenses, the standard html/head/...
2
votes
1answer
281 views

Equivalent to `ido-find-file` functionality for ivy/counsel?

I really like how ido-find-file, if it can’t find a file matching your string (and you’ve let it idle for like a second), will search your whole home directory for files matching that string, and then ...
2
votes
0answers
27 views

How can helm-find-files be adapted to include previously open files, projects etc?

After doing some more search concerning Does the recent files in emacs display files opened in previous sessions? I realize that C-x C-f is bound in my config to helm-find-files. How can helm-find-...
2
votes
0answers
125 views

find-alternate-file and move point

When using find-alternate-file, to refresh the file in the current buffer, point is always moved back to the start of the file. How can I get point to be moved to where I was in the file before ...
2
votes
0answers
414 views

Quickly navigate path with evil-mode's ex commands?

I am new to Emacs. I like how I can easily navigate to a file via helm-mode-find-file in helm. Is there any way to combine any variant of this (helm or otherwise) with evil's ex commands (eg, :e, :sp,...
2
votes
2answers
177 views

find-file-hook but only if file is selected

This is pretty simple, I'm trying to find (or build) a hook that fires when files are visited and selected (i.e. immediately displayed). Background I'm writing a UI centric entry for find-file-hook, ...
1
vote
1answer
271 views

docview: suppress “File X is too large, really open?” confirmation

Is it possible to avoid the "File X is too large, really open?" confirmation? If not, would it be possible for Emacs to remember my answer the first time I visited a large file? If I visited it once,...