What is the easiest way to open a txt file whose path has to be found using the shell find command?
For example, let say I want to open a file that I know is (uniquely) named example.txt and which I know is "somewhere I can find it using the shell find command".
What I do currently is this:
I do C-u (universal-argument) then M-! (shell command)
I then enter the find, for example:
find . -iname "example.txt"
Then the full path (which I didn't know previously) appears in the buffer, I cut it, then I hit C-x C-f, I delete what written by default and then paste what I cut before.
This seems a bit long and requires quite a few keystrokes, cut'n'pasting etc.
Is there an easiest way to do the same (without writing a new custom Emacs command)?
Emacs makes a new buffer for each file that you visit. To visit a file, type C-x C-f ( find-file ) and use the minibuffer to enter the name of the desired file. While in the minibuffer, you can abort the command by typing C-g .
Use Ctrl-x f to open a file from within Emacs. Create a new file in the same way as opening a file by specifying the new filename.
To find a file in Emacs, you use the C-x C-f ( find-file ) command.
Emacs can list the names of the files in a directory as a Lisp list, or display the names in a buffer using the ls shell command. In the latter case, it can optionally display information about each file, depending on the options passed to the ls command.
Using only built-in functionality, I would:
find-file-at-point
command: M-x ffap.I use find-file-at-point
often enough that I have it bound to a dedicated key, s-\ (super-backslash).
M-x find-name-dired
Enter the dir (defaults to current) and filename (shell globs work too) and you'll get a virtual dired buffer with the results. Go the file you want and hit 'a
'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With