Add header macro
This commit is contained in:
@@ -70,6 +70,30 @@ vim.keymap.set("x", "<leader>p", "\"_dp") -- Paste after without moving selectio
|
||||
------------
|
||||
-- Macros --
|
||||
------------
|
||||
-- Create a header in this form:
|
||||
-- ########
|
||||
-- # Text #
|
||||
-- ########
|
||||
-- Use it like so:
|
||||
-- Text
|
||||
-- # (Border line, place your cursor here
|
||||
-- Run Macro
|
||||
vim.keymap.set("n", "<leader>h", "0\"xy$k\"xPa <Esc>A <Esc>\"xpyyP:s;.;x;g<CR>j$<C-v>k$olkdyyjpj\"_dd")
|
||||
-- How it works:
|
||||
-- 0\"xy$k\"xPa <Esc>A <Esc>\"xpyyP:s;.;x;g<CR>j$<C-v>k$olkdyyjpj\"_dd
|
||||
-- ^
|
||||
-- - yank text on line into register x
|
||||
-- - paste it before and after the line aboth
|
||||
-- 0\"xy$k\"xPa <Esc>A <Esc>\"xpyyP:s;.;x;g<CR>j$<C-v>k$olkdyyjpj\"_dd
|
||||
-- ^
|
||||
-- - yank the text line and paste it aboth
|
||||
-- - substitute every character with the filler text: :s;.;<C-r>x:g (<C-r> = read register)
|
||||
-- 0\"xy$k\"xPa <Esc>A <Esc>\"xpyyP:s;.;x;g<CR>j$<C-v>k$olkdyyjpj\"_dd
|
||||
-- ^
|
||||
-- - with visual block make both line equal length
|
||||
-- - make a copy of the upper line and paste it below
|
||||
-- - delete the left over line
|
||||
|
||||
-- format a markdown table inside visual selection
|
||||
vim.keymap.set("v", "<leader>mt", ":!column -t -s '|' -o '|'<CR>", { desc = "Format markdown table" })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user