为什么 Vim 用户会喜欢 Kakoune 文本编辑器？
Kakoune

> 
> 这个编辑器可能会让人联想到 Vim，但它也提供了很多自己独特的功能和特性。
> 
> 
> 


![](/data/attachment/album/202012/25/233039wpnwnwakzn1zwa33.jpg)


[Kakoune](https://kakoune.org/) 文本编辑器的灵感来源于 Vi。它拥有简约的界面、简短的键盘快捷键以及独立的编辑和插入模式，乍一看确实[看起来和感觉很像 Vi](/article-12947-1.html)。然而，Kakoune 编辑器在设计和功能上都有自己独特的风格，与其说是另一个 Vim，不如说是它是它自己。


### 安装


在 Linux 和 BSD 上，你可以从你的发行版的软件仓库或 port 树上安装 Kakoune。例如，在 Fedora、CentOS 或 RHEL 上：



```
$ sudo dnf install kakoune

```

在 Debian、Ubuntu 或类似的系统上：



```
$ sudo apt install kakoune

```

在 macOS 上，你可以使用 Homebrew：



```
$ brew install kakoune

```

或者，你也可以[从源码构建](https://github.com/mawww/kakoune)。


启动 Kakoune 的命令是 `kak`。你可以启动 Kakoune 打开空文件，也可以在启动时包含文件名让它打开：



```
$ kak example.txt

```

### 使用 Kakoune


当你启动 Kakoune（不带文件名）时，除了在窗口底部有一个小的状态栏外，它在你的终端中打开的大部分是空的缓冲区。像 Vim 一样，Kakoune 以“正常”模式启动，它把按键作为命令，不向缓冲区输入文本。要进入*插入模式*，你必须按 `i`（代表<ruby> 插入 <rt>  Insert </rt></ruby>）或 `a`（代表<ruby> 追加 <rt>  Append </rt></ruby>）。


在插入模式下，Kakoune 的操作和其他编辑器一样。你在键盘上输入，然后你输入的字符就会显示在缓冲区里。在插入模式下，你可以使用方向键来浏览缓冲区。


### 正常模式


在正常模式下，你可以发出导航和文本编辑命令。这是从 Vi 传统中借用的最明显的功能。编辑命令包括复制、剪切（在传统的 Unix 编辑术语中，称为 “<ruby> 猛拉 <rt>  yank </rt></ruby>”）、粘贴单词和行、撤销、转换字符大小写等功能。下面是一些基础：


* `d`：复制并删除当前选择（现代术语中的“剪切”）
* `c`：复制并删除当前选择，并进入插入模式
* `Esc+Alt+d`：删除当前选择
* `y`：复制选择
* `p`：粘贴
* `<`：取消所选行的缩进
* `u`：撤消
* `U`：重做
* `：转为小写
* `~`：转换为大写


### 选择


在 Kakoune 中，你的光标是一个单字符的移动选区。除非你扩展你的选区，否则任何影响选区的命令都只适用当前光标位置。例如，如果你的光标悬停在字母 `n` 上，那么复制命令（正常模式下的 `c`）会将字母 `n` 复制到剪贴板，而粘贴命令（正常模式下的 `p`）则会将字母 `n` 粘贴到缓冲区。


从单个字符扩展选区的最简单方法是进入正常模式，按下 `Shift` 键，同时用方向键移动光标。然而，有几种方法可以根据某些标准来扩展选区。例如，`Alt+l` 将选区从光标扩展到当前行的末端。


完整的文档可以在 <https://github.com/mawww/kakoune/blob/master/README.asciidoc> 中找到。


### 函数


除了这些基本的交互，你还可以执行命令来调用 Kakoune 的内置功能。要访问 Kakoune 的命令行，在普通模式下输入 `:`。在命令行中，你可以执行命令，包括打开文件的 `edit` 命令，保存缓冲区到文件的 `write` 命令，当然还有退出应用的 `quit`。


还有更多的函数，包括针对特定编程语言和文件格式的特殊选项、使用 [Ranger 文件浏览器](https://opensource.com/article/20/3/ranger-file-navigator)浏览文件系统的选项、改变颜色主题、搜索和替换文本等等。


![Kakoune](/data/attachment/album/202012/25/233225xyoiic61kycw25kz.png "Kakoune")


### 尝试 Kakoune


如果你是一个有经验的 Vim 用户，或者甚至是一个只是略知一二的人，你可能会发现 Kakoune 一开始会让你感到迷惑。它与 Vim 的相似度足以让你陷入一种虚假的熟悉感。一切都与 Vim 一模一样，直到你发现了完全不同的地方。不过，如果你是一个刚接触 Vim 编辑器的新手，或者你是一个正在寻找新挑战的 Vim 用户，那么 Kakoune 可能是你的理想编辑器。


你自己试试吧！




---


via: <https://opensource.com/article/20/12/kakoune>


作者：[Seth Kenlon](https://opensource.com/users/seth) 选题：[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
The [Kakoune](https://kakoune.org/) text editor takes inspiration from Vi. With a minimalistic interface, short keyboard shortcuts, and separate editing and insert modes, it does [look and feel a lot like Vi](https://opensource.com/article/20/12/vi-text-editor) at first. However, the Kakoune editor has its own unique style both in design and function and is better considered its own editor rather than yet another Vim.

## Install

On Linux and BSD, you can install Kakoune from your distribution’s software repository or ports tree. For example, on Fedora, CentOS, or RHEL:

`$ sudo dnf install kakoune`


On Debian, Ubuntu, or similar:

`$ sudo apt install kakoune`


On macOS, you can use Homebrew:

`$ brew install kakoune`


Alternatively, you can [build it from source code](https://github.com/mawww/kakoune).

The command to start Kakoune is `kak`

. You can start Kakoune empty, or you can include a file name for it to open upon launch:

`$ kak example.txt`


## Using Kakoune


When you launch Kakoune (without a file name), it opens a mostly empty buffer in your terminal, except for a small status bar at the bottom of the windows. Like Vim, Kakoune starts in "normal" mode, which accepts key presses as commands and does not enter text into the buffer. To enter *insert* mode, you must press either **i** (for **insert**) or **a** (for **append**).

While in insert mode, Kakoune acts mostly like any other editor. You type on your keyboard, and the characters you type show up in the buffer. While in insert mode, you can use the arrow keys to navigate through the buffer.

## Normal mode

In normal mode, you can issue navigation and text editing commands. This is the most obvious borrowed feature from the Vi tradition. Editing commands include functions to copy, cut (or "yank," in traditional Unix editing vernacular), and paste words and lines, undo, transform characters to upper or lower case, and so on. Here are some of the basics:

**d**: yank and delete current selection ("cut" in modern terminology)**c**: yank and delete current selection and enter insert mode**Esc+Alt+d**: delete current selection**y**: yank selection**p**: paste**<**: unindent selected lines**u**: undo**U**: redo**`**: transform to lower case**~**: transform to upper case

## Selection

In Kakoune, your cursor is a single-character mobile selection. Unless you extend your selection, any commands affecting a selection apply to just your cursor. For instance, if your cursor is hovering over the letter **n**, then the yank command (**c** in normal mode) copies the letter **n** to your clipboard, and the paste command (**p** in normal mode) pastes the letter **n** into the buffer.

The easiest way to extend a selection from a single character is to enter normal mode and press the **Shift** key while moving your cursor with the arrow keys. There are, however, several methods of extending a selection based on certain criteria. For instance, **Alt+l** extends a selection region from your cursor to the end of the current line.

Full documentation is available at [https://github.com/mawww/kakoune/blob/master/README.asciidoc](https://github.com/mawww/kakoune/blob/master/README.asciidoc).

## Functions

In addition to these basic interactions, you can also issue commands to invoke the built-in functions of Kakoune. To access the Kakoune’s command line, type `:`

in normal mode. From the command line, you can issue commands, including the essential **edit** command to open a file, the **write** command to save your buffer to a file, and of course, **quit** to exit the application.

There are many more functions, including special options for specific programming languages and file formats, an option to use the [Ranger file navigator](https://opensource.com/article/20/3/ranger-file-navigator) to browse your file system, change your color theme, search and replace text, and much more.

![Kakoune Kakoune](https://opensource.com/sites/default/files/kakoune-screenshot.png)

## Try Kakoune

If you’re an experienced Vim user or even someone with just a passing competency, you might find Kakoune disorienting at first. It’s just similar enough to Vim to lull you into a false sense of familiarity—everything works exactly like Vim until it’s drastically different. However, if you’re new to Vim-like editors, or you’re a Vim user looking for a new challenge, then Kakoune could be an ideal editor for you.

Try it for yourself!

## 1 Comment