编辑 .cfg 会使 Ubuntu 服务器卡在 vi 编辑器中
我正在尝试按照教程在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我建议初学者使用
nano
(如果您使用图形界面,则使用gedit
)而不是vi
。 vi/vim 是一个很棒的编辑器,但更难使用。由于您有一个空白文件,只需按 Escape 键退出,然后按
:q!
I'd suggest using
nano
(orgedit
if you're graphical) instead ofvi
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!
按 Esc 键然后输入 :q!并按回车键。
Press escape then type :q! and press enter.
按 Ctrl+C,然后尝试输入 :q!
Press Ctrl+C and then try entering :q!
如果您有一列波形符,则您打开了一个空文件。
要退出编辑器,请输入; :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>
要立即解决问题,请输入
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.