编辑 .cfg 会使 Ubuntu 服务器卡在 vi 编辑器中

发布于 2024-10-01 05:44:10 字数 275 浏览 0 评论 0原文

我正在尝试按照教程在 Ubuntu 服务器(虚拟机上)上安装一些程序。我现在处于它说我需要编辑 .cfg 文件的部分。环顾四周后,我发现

sudo vi /path/file.cfg

可以用来在命令行中编辑文件。

输入后,我得到一行:

~  
~  
~  
~  

我按了 Enter,现在我被困在空白处。

我该如何摆脱它?如何在 Ubuntu 服务器上的命令行中编辑和保存 .cfg 文件?

I am trying to install some programs on an Ubuntu server (on a virtual machine) by following a tutorial. I am at the part where it says I need to edit a .cfg file. After looking around I found

sudo vi /path/file.cfg

could be used to edit the file in the command line.

After I typed that, I got a row of:

~  
~  
~  
~  

I pressed enter and now I am stuck in a blank space.

How do I get out of it? How do I edit and save my .cfg files in command line on an Ubuntu server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

吹泡泡o 2024-10-08 05:44:10

我建议初学者使用 nano(如果您使用图形界面,则使用 gedit)而不是 vi。 vi/vim 是一个很棒的编辑器,但更难使用。

由于您有一个空白文件,只需按 Escape 键退出,然后按 :q!

I'd suggest using nano (or gedit if you're graphical) instead of vi for beginners. vi/vim is a great editor, but harder to use.

Since you have a blank file up, simply quit by pushing Escape, then :q!

天涯沦落人 2024-10-08 05:44:10

按 Esc 键然后输入 :q!并按回车键。

Press escape then type :q! and press enter.

帅冕 2024-10-08 05:44:10

按 Ctrl+C,然后尝试输入 :q!

Press Ctrl+C and then try entering :q!

节枝 2024-10-08 05:44:10

如果您有一列波形符,则您打开了一个空文件。

要退出编辑器,请输入 ; :q

如果您想保存内容,请输入 ; :x

If you got a column of tilde's, you opened an empty file.

To quit the editor, type <ESC> :q <ENTER>

if you want to save your contents, type <ESC> :x <ENTER>

飘落散花 2024-10-08 05:44:10

要立即解决问题,请输入 Esc :q!

为了确保 vi 不会再次出现,除非您显式调用它,您应该将以下行添加到 ~/.bashrc 文件中:


导出编辑器=emacs

(或者将 emacs 替换为您选择的编辑器。)

在终端中输入 source ~/.bashrc 以使此更改立即生效。

To resolve your immediately problem, type Esc :q!.

To ensure that vi doesn't show up again unless you explicitly invoke it, you should add the following line to your ~/.bashrc file:


export EDITOR=emacs

(Or replace emacs with your editor of choice.)

Type source ~/.bashrc into your terminal for this change to take effect immediately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文