[Emacs] Emacs使用Tramp Mode访问远程文件

TRAMP (Transparent Remote Access, Multiple Protocols) is for transparently accessing remote files from within Emacs. TRAMP enables an easy, convenient, and consistent interface to remote files as if they are local files.

使用方法:直接按如下格式打开远程文件即可,

C-x C-f /ssh:[email protected]:path/to/file.txt RET
C-x C-f /ssh:[email protected]:path/to/directory/ RET

注:
sftp是Secure File Transfer Protocol的缩写,即安全文件传送协议。
Tramp Mode不支持sftp协议,在打开/sftp:[email protected]:path/to/file.txt时会提示:

byte-code: Unknown method "sftp"

原因:

This is problematic with hosting accounts where access is only via sftp… other protocols (such as ssh) are disabled.

解决方案:
如果服务器还支持ssh的话,可以使用/ssh:[email protected]:path/to/file.txt代替。


参考:
EmacsWiki: Tramp Mode
TRAMP User Manual - GNU

你可能感兴趣的:([Emacs] Emacs使用Tramp Mode访问远程文件)