About me: My name is Solène Rapenne, pronouns she/her. I like learning and sharing knowledge. Hobbies: '(BSD OpenBSD Qubes OS Lisp cmdline gaming security QubesOS internet-stuff). I love percent and lambda characters. Qubes OS core team member, former OpenBSD developer solene@. No AI is involved in this blog.

Contact me: solene at dataswamp dot org or @solene@bsd.network (mastodon).

I'm a freelance OpenBSD, FreeBSD, Linux and Qubes OS consultant, this includes DevOps, DevSecOps, technical writing or documentation work. If you enjoy this blog, you can sponsor my open source work financially so I can write this blog and contribute to Free Software as my daily job.

Kakoune editor cheatsheet

Written by Solène, on 02 December 2020.
Tags: #kakoune #editor #cheatsheet

Comments on Fediverse/Mastodon

This is a simple kakoune cheat sheet to help me (and readers) remember some very useful features.

To see kakoune in action.

Video showing various features in made with asciinema.

Official kakoune website (it has a video)

1. Commands (in command mode) §

1.1. Select from START to END position. §

Use Z to mark start and alt+z i to select unti current position.

1.2. Add a vertical cursor (useful to mimic rectangle operation) §

Type C to add a new cursor below your current cursor.

1.3. Clear all cursors §

Type space to remove all cursors except one.

1.4. Pasting text verbatim (without completion/indentation) §

You have to use "disable hook" command before inserting text. This is done with \i with \ disabling hooks.

1.5. Split selection into cursors §

When you make a selection, you can use s and type a pattern, this will create a new cursor at the start of every pattern match.

This is useful to make replacements for words or characters.

A pattern can be a word, a letter, or even ^ to tell the beginning of each line.

2. How-to §

In kakoune there are often multiples way to do operations.

2.1. Select multiples lines §

2.1.1. Multiples cursors §

Go to first line, press J to create cursors below and press X to select whole lines of every cursors.

2.1.2. Using start / end markers §

Press Z on first line, and alt+z i on last line and then press X to select whole lines of every lines.

2.1.3. Using selections §

Press X until you reach the last line.

2.2. Replace characters or words §

Make a selection and type |, you are then asked for a shell command, you have to use sed.

Sed can be used, but you can also select the lines and split the selection to make a new cursor before each word and replace the content by typing it, using the s command.

2.3. Format lines §

For my blog I format paragraphs so lines are not longer than 80 characters. This can be done by selecting lines and run fmt using a pipe command. You can use other software if fmt doesn't please you.