Helix：高级 Linux 用户的终端文本编辑器
编辑器 Helix
 


说到 [基于终端的文本编辑器](https://itsfoss.com/command-line-text-editors-linux/)，通常 Vim、Emacs 和 Nano 受到了关注。


这并不意味着没有其他这样的文本编辑器。Vim 的现代增强版 [Neovim](https://neovim.io/)，是许多这样的例子之一。


按照同样的思路，我想介绍另一个基于终端的文本编辑器，叫做 Helix Editor。


### Helix，一个用 Rust 编写的现代文本编辑器


![](/data/attachment/album/202106/17/131653xltiz1xmqolm0he8.jpg)


[Helix](https://helix-editor.com/) 是用 Rust 编写的，使用 Tree-sitter 进行语法高亮。开发者声称，它比正则表达式高亮更快，因为 Tree-sitter 像编译器一样将代码解析成语法树，从而给出更多的代码结构信息。


你可以跟踪局部变量，计算缩进和操作选择来选择语法节点。它足够强大，即使有语法错误也能产生结果。


Helix 的主要亮点是“多重选择”，这是基于 [Kakoune](http://kakoune.org/) 的。


内置的语言服务器支持提供上下文感知补全、诊断和代码操作。


### 在 Linux 上安装 Helix


对于 Arch 和 Manjaro 用户来说，Helix 在 AUR 中有两个包：


* [helix-bin](https://aur.archlinux.org/packages/helix-bin/): 包含来自 GitHub 发布的预构建二进制文件
* [helix-git](https://aur.archlinux.org/packages/helix-git/): 构建该仓库的主分支


作为一个 Arch 用户，我相信你可能已经知道 [如何使用 AUR 安装应用](https://itsfoss.com/aur-arch-linux/)。


对于其他 Linux 发行版，你必须使用 Cargo。Cargo 是 Rust 软件包管理器。有了它，你可以安装 Rust 包。可以认为它相当于 Python 的 PIP。


你应该能够使用你的发行版的包管理器来安装 Cargo。在基于 Ubuntu 的发行版上，可以这样安装 Cargo：



```
sudo apt install cargo

```

接下来，你要克隆 Helix 仓库：



```
git clone --recurse-submodules --shallow-submodules -j8 https://github.com/helix-editor/helix

```

进入克隆的目录中：



```
cd helix

```

现在用 `cargo` 来安装 Helix：



```
cargo install --path helix-term --features "embed_runtime"

```

最后一步是将 `hx` 二进制文件添加到 `PATH` 变量中，这样你就可以从任何地方运行它。这应该被添加到你的 `bashrc` 或 bash 配置文件中。



```
export PATH=”$HOME/.cargo/bin:$PATH”

```

现在都设置好了，你应该可以通过在终端输入 `hx` 来使用编辑器。


你可以在 Helix 的[文档页](https://docs.helix-editor.com/)上找到使用 Helix 的键盘快捷键：


* [Helix 键盘快捷键](https://docs.helix-editor.com/keymap.html)


它与 Vim 或 Neovim 相比如何？我无法说。我可以用 Vim 进行基本的编辑，但我不是 Vim 忍者。如果你是一个信奉 Vim（或 Emacs）的人，请你试试 Helix 并自己判断。




---


via: <https://itsfoss.com/helix-editor/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


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


OK
When it comes to [terminal based text editors](https://itsfoss.com/command-line-text-editors-linux/), it is usually Vim, Emacs and Nano that get the limelight.

That doesn’t mean there are not other such text editors. [Neovim](https://neovim.io/?ref=itsfoss.com), a modern enhancement to Vim, is one of many such examples.

Along the same line, I would like to introduce yet another terminal based text editor called Helix Editor.

## Helix, a modern text editor written in Rust

![helix editor screenshot](https://itsfoss.com/content/images/wordpress/2021/06/helix-editor-screenshot-800x515.png)

[Helix](https://helix-editor.com/?ref=itsfoss.com) is written in Rust and uses Tree-sitter for syntax highlighting. The developer claims that it is faster than regex highlighting because Tree-sitter parses code into syntax trees like a compiler and thus giving a lot more information about code structure.

You can track local variables, calculate indentations and manipulate selection to select syntax nodes. It is robust enough to produce results even with syntax error.

The main focus of Helix is on ‘multiple selection’. This is based on [Kakoune](http://kakoune.org/?ref=itsfoss.com).

The built-in language server support provides context aware completion, diagnostics and code actions.

## Installing Helix on Linux

For Arch and Manjaro users, Helix is available in the AUR in two packages:

[helix-bin](https://aur.archlinux.org/packages/helix-bin/?ref=itsfoss.com): contains prebuilt binary from GitHub releases[helix-git](https://aur.archlinux.org/packages/helix-git/?ref=itsfoss.com): builds the master branch of this repository

As an Arch user, you probably already know [how to install applications using AUR](https://itsfoss.com/aur-arch-linux/), I believe.

For other Linux distributions, you have to use Cargo. Cargo is a Rust package manager that allows you to [install Rust](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) packages. Consider it Rust equivalent to PIP of Python.

You should be able to install Cargo using your distribution’s package manager. On Ubuntu based distributions, install cargo like this:

`sudo apt install cargo`


Next, you clone the Helix repository:

`git clone --recurse-submodules --shallow-submodules -j8 https://github.com/helix-editor/helix`


Move to the cloned directory:

`cd helix`


And now use cargo to install Helix:

`cargo install --path helix-term --features "embed_runtime"`


One last step is to add the hx binary to the PATH variable so that you can run it from anywhere. This should be added to your bashrc or bash profile.

` export PATH=”$HOME/.cargo/bin:$PATH”`


Now that everything is set, you should be able to use the editor by typing `hx`

in the terminal.

You can find the keyboard shortcuts for using Helix on its [documentation page](https://docs.helix-editor.com/?ref=itsfoss.com):

How does it compare with Vim or Neovim? I cannot say. I can use Vim for basic editing but I am not a Vim ninja. If you are someone who swears and live by Vim (or Emacs), I let you try Helix and judge it yourself.