I connect to the remote machine with ssh [email protected]
. When I need to open a file in the remote machine I do, e.g.,
emacs /usr/share/nginx/html/index.html
and that opens the index.html
file in the shell. I noticed that some emacs commands work but others do not work. For instance, C-w
does not work; M-<
does not work. How can I fix this, and what is the best way to work with emacs and ssh?
I found this question but it made me more confused.
I generally prefer opening remote files from a local Emacs instance.
While running Emacs on your local machine, opening a remote file over ssh is not much different than opening any other file besides a slightly different syntax.
For ssh, you can type C-x C-f
. Now, in the minubuffer you want to type /ssh:user@host:/path/to/file
(Note that tab completion will work once you start typing a path. Also note the leading /
character). See the full docs here.
In your example, that would be:
C-x C-f /ssh:[email protected]:/usr/share/nginx/html/index.html
Now you can edit remote files over ssh in Emacs while using your local configuration and any installed packages, etc...