Skip to content

Kakoune Integration

The Kakoune plugin provides a modal editing experience for ABC notation, with dedicated modes for selecting musical elements and applying transforms. The keybindings follow Kakoune’s modal philosophy: enter a mode, press a key, and the operation is applied.

The plugin requires kak-lsp to be installed and configured. See the getting started page for installation instructions.

The server communicates with Kakoune over a Unix socket. The socket path is configured automatically by the plugin. If you need to override it, set the abc_socket_path option in your kakrc.

The plugin adds two entry points in normal mode (configurable via the abc_select_key and abc_transform_key options):

KeyAction
hEnter selection mode
kEnter transform mode

Selection mode lets you narrow the current selection to specific musical elements. Compose selectors by first selecting a region (e.g. with Kakoune’s built-in x to select lines), then entering selection mode to refine.

KeyAction
nSelect all notes
NSelect notes not inside chords
cSelect all chords
CSelect notes inside chords
zSelect all rests
rSelect all rhythm expressions
RSelect rhythm-bearing parents (notes/chords/rests with explicit rhythm)
KeyAction
mSelect all measures
sExpand selection to entire system(s)
xSelect individual tunes
vSelect by voice ID (prompts for input)
KeyAction
tSelect the top note of each chord
TSelect all notes except the top
bSelect the bottom note of each chord
BSelect all notes except the bottom
1-9Select the Nth note from the top of each chord

Press i for “inside” or a for “around”, then:

KeyInsideAround
cContent between chord bracketsEntire chord including brackets
gContent between grace group bracesEntire grace group including braces
fContent between inline field bracketsEntire inline field including brackets
pContent between grouping parenthesesEntire grouping including parentheses

Transform mode applies operations to the current selection. Many transforms accept a count prefix (e.g. 3p transposes up by 3 semitones).

KeyAction
pTranspose up by [count] semitones (default 1)
PTranspose down by [count] semitones (default 1)
oTranspose up by [count] octaves (default 1)
OTranspose down by [count] octaves (default 1)
KeyAction
<a-p>Harmonize up by [count] diatonic steps (default 1)
<a-P>Harmonize down by [count] diatonic steps (default 1)
<a-o>Harmonize up by [count] octaves (default 1)
<a-O>Harmonize down by [count] octaves (default 1)
KeyAction
+Add sharp
-Add flat
eEnharmonize (cycle enharmonic spellings)
ERe-spell notes to fit the key signature
KeyAction
*Multiply note length by [count] (default 2)
/Divide note length by [count] (default 2)
KeyAction
rConvert selected notes to rests
RConsolidate consecutive rests
lLegato (extend notes through following rests)
KeyAction
h4-voice close voicing
H5-voice close voicing
<a-h>6-voice close voicing
gEnter voicing submode (see below)
KeyAction
cClose voicing
2Drop-2 voicing
4Drop-2-4 voicing
3Drop-3 voicing
kCluster voicing
KeyAction
yParallel diatonic from previous chord
YParallel diatonic from next chord
<a-y>Parallel chromatic from previous chord
<a-Y>Parallel chromatic from next chord
KeyAction
vConvert voice info line to inline format
VConvert inline voice marker to info line
<a-v>Insert a voice line (prompts for voice ID)
<a-V>Add a new voice (prompts for voice ID)
KeyAction
xExplode chords into [count] voice parts (default 2)
<Wrap selection in crescendo markers
>Wrap selection in decrescendo markers
KeyAction
mExport current file to MIDI
MImport from MIDI

Verify that abcls is installed globally (npm list -g abcls). Check that kak-lsp is running by inspecting its log file (typically ~/.local/share/kak-lsp/kak-lsp.log). Make sure your kak-lsp.toml has an entry for the abc language ID pointing to abcls lsp --stdio.

The plugin creates a Unix socket for communication between the editor and the server. If you see socket errors, check that the socket directory exists and is writable. The default socket path can be overridden with the abc_socket_path option.

The plugin’s keybindings are only active in buffers with the abc filetype. Make sure your file has a .abc or .abcx extension, or set the filetype manually with :set buffer filetype abc.