Try Kakoune for a modern Vi | Enable Sysadmin – Red Hat

The Vi text editor has been around for a long time, has many fans and users, and ships with almost all available POSIX systems. To its credit, Vi hasn’t changed much, although it has managed to experience some major improvements (in fact, most Vi users actually use Vi-improved or Vim).

However, one of the best things about open source is how it can be adapted and iterated, so you might wonder what Vi would look like if it had been invented today. You can take a look at an alternate timeline with Kakoune, a modern editor similar to Vi that incorporates ideas from current editors as well as Vi and Vim.

Install Kakoune In

Fedora, you can install Kakoune from its repository:

$ sudo dnf kakoune

In Red Hat Enterprise Linux (RHEL), CentOS 7, and CentOS Stream, Kakoune is available in the EPEL project

. Using Kakoune Like Vi,

Kakoune

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

This command opens the sample file.txt in Kakoune

or creates the file if it does not 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 app, as if you’re using a mouse to interact with GUI apps. In Kakoune, all interaction happens with the keyboard, whether you’re moving the cursor up or down a line, removing a character (or a word or line), copying and pasting, and anything else you can do in a text editor other than enter text.

To enter insert mode, press i. In insert mode, write and edit text as you would in any other editor. Unlike Vi, Kakoune favors the modern keyboard, so keys like Home and End and all arrow keys are considered standard keys for common actions like moving at the beginning or end of a line. There is not much to learn about insertion mode. It inserts text, and it can also be in Gedit or Notepadqq.

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

By combining common navigation with selection, Kakoune is usually one step ahead of you. Consider this: when you jump forward a word, you may simply be jumping forward a word, in which case a selection is not important. However, sometimes when you jump forward a word, it’s because you need to select that word so you can copy or delete 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 in mind with this handy Linux command cheat sheet. ]

The

Kakoune clip wizard presents an anthropomorphic clip as an editing assistant. When you issue commands in Kakoune, your clip wizard appears and tells you all the possible endings for the command you typed.

Seth Kenlon (CC BY-SA 4.0)

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

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 specifically designed to allow you to do more with fewer keystrokes, so don’t be surprised if you cut a few microseconds off the time it usually takes you to adjust a configuration file with Kakoune.

  • ESC modes
  • : normal mode i: insert

  • mode I (which \’s to uppercase i): insert
  • text at the beginning of the current line A: add text

  • after the cursor A: add text
  • to the end of the current line
  • Navigation

Normal mode navigation can occur in the start row of your QWERTY keyboard:

  • h o
  • left arrow: left cursor j or down arrow: down cursor (

  • j trivially looks like a down arrow) k or up arrow: up cursor l (
  • which \’s a lowercase L) or right arrow: right cursor b: cursor at the beginning of the current word, anchor at the end e
  • : cursor at the end of the current word, anchor at the beginning

  • Start
  • : 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 to 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 close without saving

Try Kakoune Kakoune

is an interesting and progressive version of 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 Vim fan looking for something new to try, you should consider Kakoune.