订阅内容

The Vi text editor has been around for a long time, it has lots of fans and users, and it ships with nearly every POSIX system available. To its credit, Vi hasn't changed all that much, although it has managed to undergo some major improvements (in fact, most Vi users actually use Vi-improved, or Vim).

One of the greatest things about open source is how it can be adapted and iterated upon, however, and so you might wonder what Vi might look like if it had been invented today. You can get a glimpse of such an alternate timeline with Kakoune, a modern Vi-like editor incorporating ideas from current editors as well as Vi and Vim.

Install Kakoune

On Fedora, you can install Kakoune from your repository:

$ sudo dnf kakoune

On Red Hat Enterprise Linux (RHEL), CentOS 7, and CentOS Stream, Kakoune is available from the EPEL project.

Using Kakoune

Like Vi, Kakoune opens in a terminal window. The command to launch it is kak, and you can start it with or without specifying a file to open.

This command opens the file example.txt in Kakoune or creates the file if it doesn't already exist:

$ kak example.txt

Modal editing

Kakoune has two modes: normal mode and insert mode. Its default state is normal mode, and it's how you interact with Kakoune as an application, like you would use a mouse to interact with GUI applications. In Kakoune, all interaction happens with the keyboard, whether you're moving the cursor up or down a line, deleting a character (or a word or line), copying and pasting, and anything else you might do in a text editor aside from entering text.

To enter insert mode, press i. In insert mode, you type and edit text much as you would in any other editor. Unlike Vi, Kakoune favors the modern keyboard, so keys like Home and End and all the arrow keys are considered standard keys for common actions such as moving to the beginning or end of a line. There's not much to learn about insert mode. You insert text, and you may as well be in Gedit or Notepadqq.

Selecting text

Kakoune always has some text actively selected, even when it's just one character wide (in which case your cursor is also your selection). Certain navigation tasks, such as jumping to the beginning or end of a word, imply a greater selection.

By combining common navigation with selection, Kakoune is often one step ahead of you. Consider this: When you jump forward a word, you might just be jumping forward a word, in which case a selection is unimportant. However, sometimes when you jump forward a word, it's because you need to select that word so that you can copy or remove it. In those cases, Kakoune saves you the trouble of selecting an object because the navigation method has already done so.

Kakoune calls the two edges of a section the cursor and the anchor.

[ Keep common tasks top of mind with this handy Linux commands cheat sheet. ]

Paperclip assistant

Kakoune features an anthropomorphic paperclip as your editing assistant. When you issue commands in Kakoune, your paperclip assistant appears and tells you all of the potential completions for the command you've typed.

A helpful paperclip rendered in ASCII art

If you've had any previous negative experiences with paperclip assistants, don't worry. Kakoune's paperclip is actually very useful and dynamic. It's a pop-up alert that disappears once your command is sufficiently unique or complete.

Keyboard shortcuts

Unlike insert mode, normal mode has many keyboard shortcuts and commands to learn. You can learn them all or just the essentials. They're designed specifically to enable you to do more with fewer key presses, so don't be surprised if you shave a few microseconds off the time it usually takes you to adjust a config file with Kakoune.

Modes

  • ESC: normal mode
  • i: insert mode
  • I (that's a capital i): insert text at beginning of the current line
  • a: append text after the cursor
  • A: append text at end of the current line

Navigation

Navigation in normal mode can happen on the home row of your QWERTY keyboard:

  • h or Left arrow: cursor left
  • j or Down arrow: cursor down (j looks trivially like a down arrow)
  • k or Up arrow: cursor up
  • l (that's a lower-case L) or Right arrow: cursor right
  • b: cursor to the beginning of the current word, anchor at the end
  • e: cursor to end of the current word, anchor at the beginning
  • Home: go to the beginning of a line
  • End: go to the end of a line
  • gg: go to the first line of the file
  • Gk: cursor to the first line of the file, anchor at the end
  • Ge: cursor to the last line of the file, anchor at the beginning
  • 7g: go to line 7 of the file

Copy and paste

  • y: copy ("yank") selection
  • p: paste

Selection

  • w: select word
  • x: select line

Undo

  • u: undo

Save

  • :w: save
  • :wq or :ZZ: save and quit
  • :q!: force quit without saving

Try Kakoune

Kakoune is an interesting and progressive take on a classic text editor. It's different from Vim, particularly in how it treats navigation essentially the same as selection and in many of its keyboard shortcuts. However, if you're a fan of Vim looking for something new to try, you should consider Kakoune.


关于作者

Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

按频道浏览

automation icon

自动化

有关技术、团队和环境 IT 自动化的最新信息

AI icon

人工智能

平台更新使客户可以在任何地方运行人工智能工作负载

open hybrid cloud icon

开放混合云

了解我们如何利用混合云构建更灵活的未来

security icon

安全防护

有关我们如何跨环境和技术减少风险的最新信息

edge icon

边缘计算

简化边缘运维的平台更新

Infrastructure icon

基础架构

全球领先企业 Linux 平台的最新动态

application development icon

应用领域

我们针对最严峻的应用挑战的解决方案

Original series icon

原创节目

关于企业技术领域的创客和领导者们有趣的故事