Move notes inside an ASCII guitar tab without breaking the bar's width and alignment
Consider the following couple of bars
E|----------3-----2---------------------|--------------------------------------|
B|-5------3-----------------------------|---------3--------------3-------------|
G|--------------------------------------|-----4----------4---------------------|
D|--------------------------------------|-----2--------------------------------|
A|--------------------------------------|--------------------------------------|
E|--------------------------------------|--------------------------------------|
Suppose the '5' on the B string is a bit too close to the beginning of the bar
and you wanna move it, and the '3' a bit further down the bar. Put the cursor
behind the '5' and press <leader>tl three times (or press once and then tab
. if you have tpope's vim-repeat
installed). The output would look like this
E|----------3-----2---------------------|--------------------------------------|
B|-------5------3-----------------------|---------3--------------3-------------|
G|--------------------------------------|-----4----------4---------------------|
D|--------------------------------------|-----2--------------------------------|
A|--------------------------------------|--------------------------------------|
E|--------------------------------------|--------------------------------------|
You can also move individual notes and add/append bars
Here's a summary of features:
- Put the cursor behind a run,
<leader>th/<leader>tlmove the whole run left/right - Put the cursor between two notes,
<leader>tHpushes the left note back,<leader>tLpushes the right note forward - Two-digit frets (e.g.,
12) move as one unit - A note left of the cursor stays put and acts as a wall
- Moves are scoped to the current bar and never change its width
<leader>tB(or:TabbyAddBar) appends an empty measure to every string of the block at once, so all six stay aligned. The tuning prefix is left alone
Blocked or invalid moves (on a |, in the tuning, empty bar, jammed against an
edge) do nothing and say why
Using lazy.nvim:
{
'afjoseph/tabby',
dependencies = { 'tpope/vim-repeat' },
config = function()
require('tabby').setup({
-- All the configs below are also the default ones. I'm leaving them here
-- for reference
keymap_group_left = '<leader>th',
keymap_group_right = '<leader>tl',
keymap_note_left = '<leader>tH',
keymap_note_right = '<leader>tL',
keymap_add_bar = '<leader>tB',
bar_width = 38,
})
end,
}The string manipulation logic is in ./lua/tabby/core.lua and it's tested in
pure lua with just test (you need Justfile)