ue编辑器 设置unix_UNIX编辑器

ue编辑器 设置unix

Any UNIX system provides many different editors out of the box. In this section I will describe the most popular ones showing the basics of working with them. vim and emacs in particular have lots and lots of different commands, have plugins, and so you can spend years using them just scratching the surface of what’s possible.

任何UNIX系统都提供许多开箱即用的编辑器。 在本节中,我将描述最受欢迎的那些,展示与他们合作的基本知识。 特别是vimemacs有很多不同的命令,有插件,因此您可以花费数年的时间使用它们,只是摸索了一切。

ed (ed)

ed is the original UNIX text editor, and it’s the most basic you can work with. It’s also very rarely used, if ever used, by most people.

ed是原始的UNIX文本编辑器,它是您可以使用的最基本的。 大多数人也很少使用(如果曾经使用过)

Run it by typing ed. This starts an interactive session. Enter in write mode by typing a on a single line, and press enter. Then type everything you want, and once you are done, write just a dot (.) on a line and press enter.

输入ed运行它。 这将启动一个交互式会话。 通过在一行上键入a进入写入模式,然后按enter 。 然后键入您想要的所有内容,完成后,在一行上只写一个点( . ),然后按enter键。

Now type w followed by a file name to save the buffer to a file. It will return the number of bytes written to the file.

现在,键入w然后输入文件名,以将缓冲区保存到文件中。 它将返回写入文件的字节数。

You can then press q to quit.

然后,您可以按q退出。

You can edit a file with ed by invoking it with the file name: ed <filename>. When you press a to add, you add content to the bottom of the file.

您可以编辑与文件ed与文件名调用它: ed <filename> 。 按a进行添加时,将内容添加到文件的底部。

Inside an ed session you can type ,p to print the current file content.

ed会话中,您可以键入,p以打印当前文件内容。

vi / vim (vi / vim)

vim is a very popular file editor, especially among programmers. It’s actively developed and frequently updated, and there’s a very big community around it. There’s even a Vim conference!

vim是一种非常流行的文件编辑器,尤其是在程序员中。 它是积极开发并经常更新的,并且周围有很大的社区。 甚至有一个Vim会议

vi in modern systems is just an alias to vim, which means vi improved.

vi在现代系统中只是一个别名vim ,该装置vim证明。

You start it by running vi on the command line.

您可以通过在命令行上运行vi来启动它。

You can specify a filename at invocation time to edit that specific file:

您可以在调用时指定文件名来编辑该特定文件:

vi test.txt

You have to know that Vim has 2 main modes:

您必须知道Vim有2种主要模式:

  • command (or normal) mode

    命令 (或正常 )模式

  • insert mode

    插入模式

When you start the editor, you are in command mode. You can’t enter text like you expect from a GUI-based editor. You have to enter insert mode. You can do this by pressing the i key. Once you do so, the -- INSERT -- word appear at the bottom of the editor:

启动编辑器时,您处于命令模式。 您无法从基于GUI的编辑器中输入期望的文本。 您必须进入插入模式 。 您可以通过按i键来执行此操作。 完成后,在编辑器的底部将显示-- INSERT --单词:

Now you can start typing and filling the screen with the file contents:

现在,您可以开始输入文件内容并在屏幕上填充:

You can move around the file with the arrow keys, or using the h - j - k - l keys. h-l for left-right, j-k for down-up.

您可以使用箭头键或使用h - j - k - l键在文件中移动。 hl代表左右, jk代表向下。

Once you are done editing you can press the esc key to exit insert mode, and go back to command mode.

完成编辑后,可以按esc键退出插入模式,然后返回到命令模式

At this point you can navigate the file, but you can’t add content to it (and be careful which keys you press as they might be commands).

此时,您可以浏览文件,但是不能向其中添加内容(请注意按哪个键,因为它们可能是命令)。

One thing you might want to do now is saving the file. You can do so by pressing : (colon), then w.

您现在可能要做的一件事就是保存文件 。 您可以按:冒号),然后按w

You can save and quit pressing : then w and q: :wq

您可以按:然后按wq :wq 保存并退出。

You can quit without saving, pressing : then q and !: :q!

您可以不保存退出 ,按:然后按q! :q!

You can undo and edit by going to command mode and pressing u. You can redo (cancel an undo) by pressing ctrl-r.

您可以通过进入命令模式并按u撤消和编辑。 您可以通过按ctrl-r 重做 (取消撤消)。

Those are the basics of working with Vim. From here starts a rabbit hole we can’t go into in this little introduction.

这些是使用Vim的基础知识。 从这里开始一个兔子洞,在这个小介绍中我们不能介绍。

I will only mention those commands that will get you started editing with Vim:

我只会提及那些使您开始使用Vim进行编辑的命令:

  • pressing the x key deletes the character currently highlighted

    x键删除当前突出显示的字符

  • pressing A goes at the end of the currently selected line

    A转到当前所选行的末尾

  • press 0 to go to the start of the line

    0转到行的开头

  • go to the first character of a word and press d followed by w to delete that word. If you follow it with e instead of w, the white space before the next word is preserved

    转到单词的第一个字符,然后按d然后按w删除该单词。 如果用e而不是w跟随它,则保留下一个单词之前的空白

  • use a number between d and w to delete more than 1 word, for example use d3w to delete 3 words forward

    使用dw之间的数字删除一个以上的单词,例如,使用d3w向前删除3个单词

  • press d followed by d to delete a whole entire line. Press d followed by $ to delete the entire line from where the cursor is, until the end

    d其次d删除整个整条生产线。 按d然后按$以删除光标所在的整行,直到结尾

To find out more about Vim I can recommend the Vim FAQ and especially running the vimtutor command, which should already be installed in your system and will greatly help you start your vim explorations.

要了解有关Vim的更多信息,我可以推荐Vim FAQ ,尤其是运行vimtutor命令,该命令应该已经安装在您的系统中,并且将大大帮助您开始进行vim探索。

emacs (emacs)

emacs is an awesome editor and it’s historically regarded as the editor for UNIX systems. Famously vi vs emacs flame wars and heated discussions caused many unproductive hours for developers around the world.

emacs是一个了不起的编辑器,并且在历史上一直被视为UNIX系统编辑器。 著名的vi vs emacs火焰之战和激烈的讨论对世界各地的开发人员造成了很多无用的时间。

emacs is very powerful. Some people use it all day long as a kind of operating system (https://news.ycombinator.com/item?id=19127258). We’ll just talk about the basics here.

emacs非常强大。 有人整日使用它作为一种操作系统( https://news.ycombinator.com/item?id=19127258 )。 我们将在这里讨论基础知识。

You can open a new emacs session simply by invoking emacs:

您只需调用emacs即可打开一个新的emacs会话:

macOS users, stop a second now. If you are on Linux there are no problems, but macOS does not ship applications using GPLv3, and every built-in UNIX command that has been updated to GPLv3 has not been updated. While there is a little problem with the commands I listed up to now, in this case using an emacs version from 2007 is not exactly the same as using a version with 12 years of improvements and change. This is not a problem with Vim, which is up to date. To fix this, run brew install emacs and running emacs will use the new version from Homebrew (make sure you have Homebrew installed)

macOS用户,请立即停止。 如果您使用的是Linux,则没有问题,但是macOS不会使用GPLv3交付应用程序,并且尚未更新为已更新为GPLv3的每个内置UNIX命令。 尽管我到目前为止列出的命令存在一些问题,但是在这种情况下,使用2007年的emacs版本与使用经过12年改进和更改的版本并不完全相同。 这不是Vim的问题,它是最新的。 要解决此问题,请运行brew install emacs ,运行emacs将使用Homebrew的新版本(确保已安装Homebrew )

You can also edit an existing file calling emacs <filename>:

您还可以编辑一个emacs <filename>的现有文件:

You can start editing and once you are done, press ctrl-x followed by ctrl-w. You confirm the folder:

您可以开始编辑,一旦完成,请按ctrl-x然后按ctrl-w 。 您确认文件夹:

and Emacs tell you the file exists, asking you if it should overwrite it:

然后Emacs告诉您该文件存在,并询问您是否应该覆盖它:

Answer y, and you get a confirmation of success:

回答y ,您将确认成功:

You can exit Emacs pressing ctrl-x followed by ctrl-c. Or ctrl-x followed by c (keep ctrl pressed).

您可以先按ctrl-x再按ctrl-c退出Emacs。 或按ctrl-x然后按c (按住ctrl键)。

There is a lot to know about Emacs. More than I am able to write in this little introduction. I encourage you to open Emacs and press ctrl-h r to open the built-in manual and ctrl-h t to open the official tutorial.

关于Emacs有很多知识。 在这个小介绍中,我所能写的更多。 我鼓励您打开Emacs并按ctrl-h r打开内置手册,然后按ctrl-h t打开官方教程。

nano (nano)

nano is a more beginner friendly editor.

nano是对初学者更友好的编辑器。

Run it using nano <filename>.

使用nano <filename>运行它。

You can directly type characters into the file without worrying about modes.

您可以直接在文件中键入字符,而不必担心模式。

You can quit without editing using ctrl-X. If you edited the file buffer, the editor will ask you for confirmation and you can save the edits, or discard them. The help at the bottom shows you the keyboard commands that let you work with the file:

您可以退出而无需使用ctrl-X进行编辑。 如果您编辑了文件缓冲区,编辑器将要求您确认,然后可以保存或放弃编辑。 底部的帮助向您显示了用于处理文件的键盘命令:

pico is more or less the same, although nano is the GNU version of pico which at some point in history was not open source and the nano clone was made to satisfy the GNU operating system license requirements.

pico大致相同,尽管nanopico的GNU版本,在历史上某些时候它不是开源的,并且nano克隆是为了满足GNU操作系统许可要求而制成的。

翻译自: https://flaviocopes.com/unix-editors/

ue编辑器 设置unix

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值