Subscribe to the feed

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.


About the author

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

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech