Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open file in Emacs via eshell?

When in eshell is there a command for opening a file in another buffer?

like image 325
hks Avatar asked Feb 04 '11 21:02

hks


People also ask

How do I open a file in Emacs?

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. The new file will not be saved unless specified. Save a file that is currently open by entering the Ctrl-x Ctrl-s command.

How do I open a Emacs file in Linux?

You can open a file by specifying the filename when you start Emacs (as we did earlier) or by typing C-x C-f (the long command name for this is find-file). C-x C-f creates a new buffer that has the same name as the file. Emacs prompts you for a filename; respond by typing the filename, followed by RETURN.

What is a buffer in Emacs?

Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.

What is the command to search a file from within Emacs?

To find a file in Emacs, you use the C-x C-f ( find-file ) command.


2 Answers

In eshell, you don't have to use the entire path when using the find file command. Hitting C-x C-f is the same as typing find-file, and eshell sets the directory to the one you are currently browsing. This is the advantage to me over using ansi-term. Try it out.

like image 43
Benjamin Handelman Avatar answered Sep 21 '22 10:09

Benjamin Handelman


You can call elisp functions directly. So to open a file, call find-file on the filename. Example:

~ $ ls myfile ~ $ (find-file "myfile") 

Parentheses and quotes are optional, so this works too:

~ $ find-file myfile 
like image 87
ataylor Avatar answered Sep 21 '22 10:09

ataylor