17 votes
Accepted

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

M-x url-handler-mode C-x C-f http://emacs.stackexchange.com/questions/21180/is-there-a-way-to-show-open-a-file-from-a-uri-url This opens the HTML file of this stackexchange question in your Emacs.
Michael Albinus's user avatar
10 votes
Accepted

How to check, if a file is already visited?

(get-file-buffer filename) returns the buffer visiting filename, or nil if there is none. https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-File-Name.html Edit: justbur proposes using ...
Vera Johanna's user avatar
10 votes
Accepted

open files at last-edited position

The built-in library saveplace.el contains a commentary that states: ;; Automatically save place in files, so that visiting them later ;; (even during a different Emacs session) automatically moves ...
lawlist's user avatar
  • 19.1k
7 votes
Accepted

Omit current and parent directories in Ivy find-file completion

When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates. This is what the user option ivy-extra-directories is for: ivy-extra-directories is a variable defined ...
Basil's user avatar
  • 12.4k
7 votes

How show recent files?

install counsel (https://oremacs.com/2015/04/09/counsel-completion/) Run M-x counsel-recentf Press C-c C-o to export the file list to a buffer
chen bin's user avatar
  • 4,867
7 votes

Template for new file

See standard library auto-insert.el, which is part of Emacs. To use it, customize options auto-insert and auto-insert-directory, then do this: (add-hook 'find-file-hook 'auto-insert) auto-insert ...
Drew's user avatar
  • 77.5k
7 votes

Template for new file

At @Drew's suggestion, here's a short example of combining YASnippet and auto-insert to achieve dynamic or interactive boilerplate. From my ~/.emacs.d/init.el: ;;{{{ yasnippet & auto-insert (...
nega's user avatar
  • 3,221
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

Find file in directory

It sounds like find-file, C-x C-f does what you want. There are more sophisticated options available for this kind of basic operation: ido-find-file, which is built-in to Emacs. You can see the ...
Tyler's user avatar
  • 22.3k
6 votes
Accepted

C-x C-f results in the error message: "Wrong type argument: commandp, counsel-find-file"

You have bound C-x C-f to the command counsel-find-file, which is part of the Counsel Package. Apparently, the counsel package is not getting loaded by your config files, so when you try to call it, ...
Tyler's user avatar
  • 22.3k
6 votes
Accepted

ivy counsel find-file with similar name

Using C-M-j when you're at prompt line. Binds to ivy-immediate-done As manual states it goes with current input instead the current candidate.
Muihlinn's user avatar
  • 2,624
5 votes

Regex for any file not ends with

The way you intended this to be done: (find-lisp-find-files "." "\\(^..?\\|py[^co]\\|[^p]..\\|.[^y].\\)$") which, probably requires some explanation. Why your attempt didn't work Emacs doesn't ...
wvxvw's user avatar
  • 11.4k
5 votes
Accepted

Regex for any file not ends with

Note that (?!.*pyc$) is regular expression syntax of perl (zero negative lookahead) that does not work in emacs. You can use (require 'cl-lib) (cl-remove-if (lambda (file) (or (...
Tobias's user avatar
  • 33.2k
5 votes
Accepted

Function to open all Org files in a folder recursively

Here is a solution for org files. I wouldn't recognise a Fountain file if I saw one, so you'd have to provide that one yourself. The second argument to directory-files-recursively is a regular ...
Harald Hanche-Olsen's user avatar
5 votes

How to pipe large files through fold before opening?

Have emacs read from stdin device and insert contents into *scratch* buffer. $ fold -w80 myfile | emacs --insert /path/to/stdin Note: You will need to update /path/to/stdin path e.g. $ fold -w80 ...
Melioratus's user avatar
  • 4,644
5 votes
Accepted

Don't show "." and ".." in counsel-find-file

You can hide those entries with (setq ivy-extra-directories nil).
Swarnendu Biswas's user avatar
4 votes
Accepted

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

This behavior is based on ffap-string-at-point-mode-alist. Take a look at the current value and doc string. You'll see an entry like this: (file "--:\\\\${}+<>@-Z_[:alpha:]~*?" "<@" "@>;...
glucas's user avatar
  • 20.6k
4 votes
Accepted

How to create a file from a template if it does not exist or open existing copy?

You could use this version of the function: (defun journal-entry () (interactive) (let* ((daily-name (format-time-string "%Y-%m-%d)")) (journal-path "~/Dropbox (Personal)/journal/") (...
Konstantin Morenko's user avatar
4 votes

Aliases on minibuffer for quick switching of directories

There are several things you could do. Use pattern matching that abbreviates parts of the directory hierarchy or file name. Even vanilla Emacs lets you do this to some extent (e.g. with wildcard * ...
Drew's user avatar
  • 77.5k
4 votes

Regex for any file not ends with

Elisp regular expressions are hard to read, hard to get right and even harder to maintain. Here are two alternative approaches: foreign-regexp.el -- https://github.com/k-talo/foreign-regexp.el ...
Heikki's user avatar
  • 3,066
4 votes

Quick jump to a specific line of a file

You can add this functionality to find-file-at-point with the following elisp snippet in your init file. Please be aware that this method does not take into account that /folder/subfolder/file.xml:...
Tobias's user avatar
  • 33.2k
4 votes

Quick jump to a specific line of a file

If you added a trailing colon to each line like so: /folder/subfolder/file.xml:435: Then enabling M-x compilation-minor-mode will have the desired outcome, such that you can type RET or use mouse-1 ...
phils's user avatar
  • 51.1k
4 votes
Accepted

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

Asuming that C-x C-f is bound to ido-find-file you drop back to the non-Ido version by typing C-x C-f again or just C-f. This will allow you to create the file you want without Ido interfence.
FredrikHedman's user avatar
4 votes

How do I open a file in spacemacs?

Since Spacemacs is build upon Emacs, the regular command for find-file works. Pressing C-x C-f (that is, control x control f) will open the file menu. Spacemacs also includes the Emacs tutorial, ...
Lorem Ipsum's user avatar
  • 4,507
4 votes

Find file in directory

The general answer is find-file(-other-window): C-x C-f (C-x 4 f). But it helps to use Dired (C-x 4 d) in the directory you want. That sets the default-directory, so C-x C-f looks for files in that ...
Drew's user avatar
  • 77.5k
4 votes

how to open a file without using Ivy

In default Ivy configurations, C-x C-f is bound to counsel-find-file which will invoke ivy-completing-read even if global ivy-mode is turned off! Rather than going through the clumsy steps of ...
gregoryg's user avatar
  • 925
4 votes
Accepted

Open file at startup from init file

You can use server-after-make-frame-hook: (add-hook 'server-after-make-frame-hook (lambda () (find-file "~/my-file.org")))
d125q's user avatar
  • 1,443
3 votes
Accepted

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

Two ways to find a file name deep in a directory, without having to drill down: SPC SPC counsel-file-jump lists all files below parent directory. But first use SPC f f (counsel-find-file) to select ...
wolfv's user avatar
  • 1,393
3 votes

Why does opening a file take so long in python mode?

I have the same issue and dug a little more into it. Launching emacs with: emacs -nw -Q lets me load any python file instantly without issues (whereas emacs -q -nw still takes forever to load even ...
drkg4b's user avatar
  • 131
3 votes

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

If you want the file "rendered", you can use the web browser eww - just do M-x eww RET url RET
asjo's user avatar
  • 1,067

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