macos 使用 mac 终端 ssh 时使用什么文本编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11020494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What text editor to use while ssh using mac terminal
提问by Tri Nguyen
I am using my Mac Terminal to SSH into my GoDaddy hosting account.
我正在使用我的 Mac 终端通过 SSH 连接到我的 GoDaddy 托管帐户。
I was wondering what text editor I could use through Terminal? I am not familiar with VIM or emacs at all so it's hard for me to use.
我想知道我可以通过终端使用什么文本编辑器?我根本不熟悉 VIM 或 emacs,所以我很难使用。
I've used gedit on Linux and quite like it. I wonder if I could install gedit on the Godaddy server?
我在 Linux 上使用过 gedit 并且非常喜欢它。我想知道我是否可以在Godaddy服务器上安装gedit?
Any advice would be appreciated. I am very new to working with SSH and the terminal.
任何意见,将不胜感激。我对使用 SSH 和终端非常陌生。
回答by abarnert
There are lots of full-screen text editors, but if you want to edit files locally on your Mac and while ssh'd into a remote server without having to think about it, you really have to learn one of the ubiquitous editors.
有很多全屏文本编辑器,但是如果您想在 Mac 上本地编辑文件,并且无需考虑通过 ssh 连接到远程服务器,那么您真的必须学习一种无处不在的编辑器。
In fact, ideally you should learn the basics of all three—at least how to get out safely—because at some point, you're going to accidentally visudo with VISUAL unset or set wrong and find yourself in the wrong editor.
事实上,理想情况下,您应该学习所有这三个方面的基础知识——至少如何安全地离开——因为在某些时候,你会不小心在 VISUAL 未设置或设置错误的情况下进行 visudo,并发现自己在错误的编辑器中。
nano (and its relatives in the pico family) is by far the easiest to learn if you're coming from a TextEdit/TeachText/Notepad background. However, it's the least ubiquitous, and the least efficient with both keystrokes and screen real estate, and real Unix geeks will laugh at you if they ask "vi or emacs" and you say "nano".
vi (and its relatives—in fact, usually you're using vim, not vi) is the most ubiquitous, and by far the most efficient for?quick and simple edits. It's also much more usable from bizarre terminals like your favorite iPad ssh client (where hitting ^X is a major chore). And ultimately, most vi key sequences also work with ed and sometimes even sed, which is really handy when you're stuck on a terminal with full-screen support at all. However, it is by far the hardest to learn when you've coming from a GUI background—the idea that you can't enter or edit text in your text editor except by entering special modes is just weird.
emacs (and its relatives and simplified clones, like jove and ue) is the most efficient for doing complex operations. It's also nice that its weirder keystrokes (like ^A-F for cursor movement) are the same as the Terminal command line, libreadline, native Mac GUI text controls, and Firefox text controls. And if you really learn emacs, you can start using Aquamacs in the GUI, and programming it to automate all your tedious text editing, and so on. The only problem is that really learning emacs will take you years, and you might have other things to do with your life.
如果您来自 TextEdit/TeachText/Notepad 背景,那么 nano(及其在 pico 家族中的亲戚)是迄今为止最容易学习的。然而,它是最不普遍的,而且在击键和屏幕空间方面效率最低,如果真正的 Unix 极客问“vi 或 emacs”而你说“nano”,他们会嘲笑你。
vi(及其亲属——事实上,通常你使用的是vim,而不是vi)是最普遍的,也是迄今为止最有效的?快速和简单的编辑。它也更适用于奇怪的终端,比如你最喜欢的 iPad ssh 客户端(点击 ^X 是一件大事)。最终,大多数 vi 键序列也可以与 ed 一起使用,有时甚至可以与 sed 一起使用,当您卡在支持全屏的终端上时,这真的很方便。然而,当您具有 GUI 背景时,这是迄今为止最难学习的——除非进入特殊模式,否则您无法在文本编辑器中输入或编辑文本的想法很奇怪。
emacs(及其亲属和简化的克隆,如 jove 和 ue)是执行复杂操作最有效的。它的奇怪按键(如用于光标移动的 ^AF)与终端命令行、libreadline、本机 Mac GUI 文本控件和 Firefox 文本控件相同,这也很好。如果你真的学会了 emacs,你可以开始在 GUI 中使用 Aquamacs,并对其进行编程以自动化所有繁琐的文本编辑,等等。唯一的问题是,真正学习 emacs 需要花费数年时间,而且您的生活可能还有其他事情要做。