Linux 命令行下的最佳文本编辑器
编辑器 vi emacs vim
![](/data/attachment/album/201608/11/135524bs61phcgp8fehosq.jpg)


文本编辑软件在任何操作系统上都是必备的软件。我们在 Linux 上不缺乏[非常现代化的编辑软件](/article-7468-1.html)，但是它们都是基于 GUI（图形界面）的编辑软件。


正如你所了解的，Linux 真正的魅力在于命令行。当你正在用命令行工作时，你就需要一个可以在控制台窗口运行的文本编辑器。


正因为这个目的，我们准备了一个基于 Linux 命令行的文本编辑器清单。


### [VIM](http://www.vim.org/)


如果你已经使用 Linux 有一段时间，那么你肯定听到过 Vim 。Vim 是一个高度可配置的、跨平台的、高效率的文本编辑器。


几乎所有的 Linux 发行版本都已经内置了 Vim ，由于其特性之丰富，它已经变得非常流行了。


![](/data/attachment/album/201608/11/135548awwl55njz6ljd89j.png)


*Vim 用户界面*


Vim 可能会让第一次使用它的人感到非常痛苦。我记得我第一次尝试使用 Vim 编辑一个文本文件时，我是非常困惑的。我不能用 Vim 输入一个字母，更有趣的是，我甚至不知道该怎么关闭它。如果你准备使用 Vim ，你需要有决心跨过一个陡峭的学习路线。


但是一旦你经历过了那些，通过梳理一些文档，记住它的命令和快捷键，你会发现这段学习经历是非常值得的。你可以将 Vim 按照你的意愿进行改造：配置一个让你看起来舒服的界面，通过使用脚本或者插件等来提高工作效率。Vim 支持格式高亮，宏记录和操作记录。


在Vim官网上，它是这样介绍的：



> 
> **Vim: The power tool for everyone!**
> 
> 
> 


如何使用它完全取决于你。你可以仅仅使用它作为文本编辑器，或者你可以将它打造成一个完善的IDE（<ruby> 集成开发环境 <rp>  （ </rp> <rt>  Integrated Development Environment </rt> <rp>  ） </rp></ruby>）。


### [GNU EMACS](https://www.gnu.org/software/emacs/)


GNU Emacs 毫无疑问是非常强大的文本编辑器之一。如果你听说过 Vim 和 Emacs ，你应该知道这两个编辑器都拥有非常忠诚的粉丝基础，并且他们对于文本编辑器的选择非常看重。你也可以在互联网上找到大量关于他们的段子：


![](/data/attachment/album/201608/11/135605pg8dqk88w5dk3qiz.png)


*Vim vs Emacs*


Emacs 是一个跨平台的、既有有图形界面也有命令行界面的软件。它也拥有非常多的特性，更重要的是，可扩展！


![](/data/attachment/album/201608/11/135638nod47qdhnpn8ku6d.png)


*Emacs 用户界面*


像 Vim一样，Emacs 也需要经历一个陡峭的学习路线。但是一旦你掌握了它，你就能完全体会到它的强大。Emacs 可以处理几乎所有类型文本文件。它的界面可以定制以适应你的工作流。它也支持宏记录和快捷键。


Emacs 独特的特性是它可以“变形”成和文本编辑器完全不同的的东西。有大量的模块可使它在不同的场景下成为不同的应用，例如：计算器、新闻阅读器、文字处理器等。你甚至都可以在 Emacs 里面玩游戏。


### [NANO](http://www.nano-editor.org/)


如果说到简易方便的软件，Nano 就是一个。不像 Vim 和 Emacs，nano 的学习曲线是平滑的。


如果你仅仅是想创建和编辑一个文本文件，不想给自己找太多挑战，Nano 估计是最适合你的了。


![](/data/attachment/album/201608/11/135649qfcapakrp3esqnek.png)


*Nano 用户界面*


Nano 可用的快捷键都在用户界面的下方展示出来了。Nano 仅仅拥有最基础的文本编辑软件的功能。


它是非常小巧的，非常适合编辑系统配置文件。对于那些不需要复杂的命令行编辑功能的人来说，Nano 是完美配备。


### 其它


这里还有一些我想要提及其它编辑器：


[The Nice Editor (ne)](http://ne.di.unimi.it/): 官网是这样介绍的:



> 
> 如果你有足够的资料，也有使用 Emacs 的耐心或使用 Vim 的良好心态，那么 ne 可能不适合你。
> 
> 
> 


基本上 ne 拥有像 Vim 和 Emacs 一样多的高级功能，包括：脚本和宏记录。但是它有更为直观的操作方式和平滑的学习路线。


### 你认为呢?


我知道，如果你是一个熟练的 Linux 用户，你可以会说还有很多应该被列入 “Linux 最好的命令行编辑器”清单上。因此我想跟你说，如果你还知道其他的 Linux 命令行文本编辑器，你是否愿意跟我们一同分享？




---


via: <https://itsfoss.com/command-line-text-editors-linux/>


作者：[Munif Tanjim](https://itsfoss.com/author/munif/) 译者：[chenzhijun](https://github.com/chenzhijun) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

A text editor is a must-have application for any operating system. We have no dearth of [good text editors on Linux](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/). There is Gedit for quick text note down, there is VS Code for writing codes and more.

But those are all GUI-based editors. What if you need to [edit files in the terminal](https://learnubuntu.com/edit-files-command-line/?ref=itsfoss.com)?

Linux sysadmins need to do that on a daily basis. The average desktop Linux user may also need to edit files in the command line from time to time.

Your distribution has a terminal-based text editor installed by default. But don’t restrict yourself to just that.

Here, I have compiled a list of the **best command line text editors for Linux**. Feel free to experiment.

Please note that this is not a ranking list.

## 1. Neovim

![neovim text editor](https://itsfoss.com/content/images/wordpress/2022/09/neovim-text-editor.png)

Neovim is a fork of Vim that aims to add more extensibility while simplifying it. If you’re comfortable with Vim, you will be good to go using Neovim.

The project is being actively maintained and the progress is promising so far. Of course, unless you’re acquainted with how Vim works, you may not notice the striking difference between the two.

But, overall, Neovim tries to take Vim up a notch.

**How to install it?**

For Ubuntu-based distros, you can simply install it by typing:

`sudo apt install neovim`


For other Linux distributions or platforms, you may refer to its [official installation instructions](https://github.com/neovim/neovim/wiki/Installing-Neovim?ref=itsfoss.com) to get started.

To give you a head start, I must mention that when using the terminal, you will have to type the following to launch it (instead of neovim):

`nvim`


## 2. ne – The Nice Editor

![ne the nice editor](https://itsfoss.com/content/images/wordpress/2022/09/ne-the-nice-editor.png)

When compared to the classic and popular text editors, ne (the nice editor) is a good alternative that tries to offer advanced functionalities and make it easier to use them.

In other words, it’s a simpler alternative to Vim/Emacs offering you powerful features. It is being actively maintained. I tried it installing on [U](https://itsfoss.com/ubuntu-22-04-release-features/)buntu 22.04 and it worked just fine. You can explore more about it on their [GitHub page](https://github.com/vigna/ne?ref=itsfoss.com).

Of course, unless you test it extensively, you should take it with a pinch of salt.

**How to install it?**

You should find it available in the official repositories of your Linux distribution. For Ubuntu-based distros, you can install it using the command:

`sudo apt install ne`


You can also check out their [official download page](http://ne.di.unimi.it/?ref=itsfoss.com#downloads) for more information on other Linux distributions.

## 3. Vim

![vim text editor](https://itsfoss.com/content/images/wordpress/2022/09/vim-text-editor.png)

If you’ve been on Linux for quite some time, you must have heard about [Vim](https://www.vim.org/?ref=itsfoss.com). Vim is an extensively configurable, cross-platform, and highly efficient text editor.

It may not be suitable for newbies but it’s something every aspiring Linux System administrator should get comfortable with. You will probably find it pre-installed in your Linux distribution. It is extremely popular for its wide range of advanced features.

Vim can be quite agonizing for first-time users. I remember the first time I tried to edit a text file with Vim, I was completely puzzled. I couldn’t type a single letter on it and the funny part is, I couldn’t even figure out how to close this thing. If you are going to use Vim, you must be determined to climb up a very steep learning curve.

But after you have gone through all that, combed through its [official documentation](https://www.vim.org/docs.php?ref=itsfoss.com), and practice the commands/operations, you’ll find it worth all the time spent. Not to forget, you can use it for basic text editing or leverage its support for hundreds of programming languages, extensions, and file formats.

**How to install it?**

If you don’t have it installed already, you can just try typing in the command (on Debian-based systems) to install it:

`sudo apt install vim`


You can also find it listed in your software center of the Linux distribution you use. In either case, just head on to its [official download page](https://www.vim.org/download.php?ref=itsfoss.com) to get more details.

[Mastering Vim Quickly - Jovica IlicExiting Mastering Vim Quickly From WTF to OMG in no time](https://gumroad.com/a/322499699?ref=linuxhandbook.com)![](https://jovicailic.org/wp-content/uploads/2017/11/book_video_ebooks-1.jpg)


![](https://jovicailic.org/wp-content/uploads/2017/11/book_video_ebooks-1.jpg)

## 4. GNU Emacs

![gnu emacs text editor](https://itsfoss.com/content/images/wordpress/2022/09/gnu-emacs-text-editor.png)

GNU Emacs is undoubtedly one of the oldest and versatile text editors out there. In case you didn’t know, it was created by GNU Project founder [Richard Stallman](https://en.wikipedia.org/wiki/Richard_Stallman?ref=itsfoss.com).

Emacs is cross-platform and has both command line and a graphical user interface. It is also very rich with various features and, most importantly, extensible.

Just as Vim, Emacs too comes with a steep learning curve. But once you master it, you can completely leverage its power. Emacs can handle just about any type of text file. The interface is customizable to suit your workflow. It supports macro recording and shortcuts as well.

The unique power of Emacs is that it can be transformed into something completely different from a text editor. There is a large collection of modules that can transform the application for use in completely different scenarios, like — calendar, news reader, word processor, etc. You can even play games in Emacs!

**How to install it?**

You should find it in your software center, or if you prefer using the terminal on Ubuntu-based distros, you can type in:

`sudo apt install emacs`


You can find more information on it on their [official download page](https://www.gnu.org/software/emacs/download.html?ref=itsfoss.com#gnu-linux). Once you’re done installing, you need to type in a specific command to launch emacs in your terminal, which is:

`emacs -nw`


Basically, this command instructs not to include any window to launch the program but the terminal itself.

## 5. MCEDIT

![mcedit text editor](https://itsfoss.com/content/images/wordpress/2022/09/mcedit-text-editor.png)

Midnight Commander is a fairly popular command line file manager and mcedit is an internal file editor of GNU Midnight Commander. It’s possible that many of us forget about this text editor, which is embedded inside the midnight commander utility.

What this editor does, is open the files specified on the command line. The editor is based on the terminal version of cooledit – a standalone editor for X Window System.

**How to install it?**

mcedit comes with the Midnight Commander package. In Ubuntu, you can install it by:

`sudo apt install mc`


Once installed, you can open files by executing:

`mcedit <file name>`


For more information, you can check out their [GitHub page.](https://github.com/MidnightCommander/mc?ref=itsfoss.com)

## 6. Nano

![nano text editor](https://itsfoss.com/content/images/wordpress/2022/09/nano-text-editor.png)

When it comes to simplicity, Nano is the one. Unlike Vim or Emacs, it is suitable for beginners to get used to quickly.

If you want to simply create & edit a text file, look no further.

The shortcuts available on Nano are displayed at the bottom of the user interface. It is minimal and perfectly suitable for editing system & configuration files. For those who don’t need advanced features from a command-line text editor, Nano is the perfect pick.

If interested, you can learn [how to use Nano text editor](https://itsfoss.com/nano-editor-guide/) in our beginner’s guide.

**How to install it?**

For the most part, Nano editor should come in pre-installed on Ubuntu-based distributions. If it isn’t there, you can simply visit the [official download page](https://www.nano-editor.org/download.php?ref=itsfoss.com) to get the binaries for the distribution you want.

[How to Use Nano Text Editor in Linux [With Cheat Sheet]Though Nano is less complicated to use than Vim and Emacs, it doesn’t mean Nano cannot be overwhelming. Learn how to use the Nano text editor.](https://itsfoss.com/nano-editor-guide/)![](https://itsfoss.com/content/images/wordpress/2020/05/nano-editor-guide.png)


![](https://itsfoss.com/content/images/wordpress/2020/05/nano-editor-guide.png)

## 7. Tilde

![tilde text editor](https://itsfoss.com/content/images/wordpress/2022/09/tilde-text-editor.png)

Tilde is a terminal-based text editor tailored for users who are normally used to GUI applications.

Unlike other options mentioned in this list — this may not be a power tool. But, for basic text editing operations, this is very easy to use. You do have some advanced functionality – but that’s not something to compare with Vim/Emacs.

If you wanted to try something easy-to-use and different, this is the one I’d recommend you to try.

**How to install it?**

For Ubuntu-based distros, you can simply type the following command in the terminal:

`sudo apt install tilde`


For information on other Linux distributions, you may refer to their [GitHub page](https://github.com/gphalkes/tilde?ref=itsfoss.com) or the [download page](https://os.ghalkes.nl/tilde/download.html?ref=itsfoss.com) to explore more about it.

## 8. Micro

![micro text editor](https://itsfoss.com/content/images/wordpress/2022/09/micro-text-editor.png)

Micro is an easy-to-use and highly customizable text editor. It also implements the universal copy/paste/save shortcuts (CTRL + C/V/S), which is rare in Linux terminal editors. Another cool offering from this text editor is its plugin system and internal command mode.

Though it’s not feature-rich like Vim or other mature text editors, it can easily replace tools like Nano for occasional file editing in the terminal.

**How to install it?**

Micro is available in the repositories of all major distributions. In Ubuntu, you can install it with:

`sudo apt install micro`


For other Linux systems, you can check out their [GitHub page](https://github.com/zyedidia/micro/releases?ref=itsfoss.com). We have an article on [Micro text editor with a free cheat sheet for beginners](https://itsfoss.com/micro-editor-linux/) if you are interested.

## 9. Helix

![helix editor](https://itsfoss.com/content/images/wordpress/2022/09/helix-editor.png)

Helix editor is a rust-based terminal text editor, which is both fast and efficient in resources. It uses Tree-Sitter for syntax highlighting, which helps boost the speed. The built-in language server support provides context-aware completion, diagnostics, and code actions.

Helix editor offers several powerful tools, that can make it work like other editors like Vim and Emacs. On their website, they call themselves, a post-modern text editor, if Neovim is the modern Vim, then Helix is post-modern.

For those who are interested, you can check out a [dedicated Helix article](https://itsfoss.com/helix-editor/)

**How to install it?**

For Arch and its derivatives, there is a package available in the Community repository. Also, an [AUR package](https://aur.archlinux.org/packages/helix-git?ref=itsfoss.com) is also available, which builds the master branch.

For other Linux distributions, you have to use Cargo, the Rust Package Manager.

You should be able to install Cargo using your distribution package manager Also, you need to make sure that Git is installed. On Ubuntu-based distributions, install both like this:

`sudo apt install git cargo`


Next, you should use the below commands one by one.

```
git clone https://github.com/helix-editor/helix
cd helix
cargo install --path helix-term
```


Helix also needs its runtime files so make sure to copy/symlink the `runtime/`

directory into the config directory. This location can be overridden via the `HELIX_RUNTIME`

environment variable.

`ln -s $PWD/runtime ~/.config/helix/runtime`


Now you should add the installed bin directory to your PATH.

`export PATH=$PATH:/home/team/.cargo/bin`


You can [check out their official page](https://docs.helix-editor.com/install.html?ref=itsfoss.com) for more information.

## Wrapping Up

If you are an experienced Linux user, you must have heard of most of the options mentioned in this list, if not all.

For most users, going with Nano, Vim or Emacs should be good enough. The seasoned terminal dwellers could experiment with the likes of Micro, Helix or some other terminal text editors.

That’s just my recommendation. And I would like to know yours. Which text editor do you prefer in the command line? Did you find a new, interesting one on this list? Share it in the comments.