Textobj for backtick, this plugin is better than default behavior in Neovim that it allows user to choose content in multilines.
For the following sample text, users can use textobj motions to choose/yank/delete/cut content between two backticks.
const SampleString = ` SELECT
id,
first_name,
last_name,
gender,
age
from
user
where id = $1; `
Keymap: i`
Complex keymap: <Plug>(textobj-backtick-i)
No backticks in the beginning and ending, no white spaces in the beginning and ending.
SELECT
id,
first_name,
last_name,
gender,
age
from
user
where id = $1;
Keymap: a`
Complex keymap: <Plug>(textobj-backtick-a)
` SELECT
id,
first_name,
last_name,
gender,
age
from
user
where id = $1; `
This case doesn't have keymap in default, you can add keymap by yourself in config.
Complex keymap: <Plug>(textobj-backtick-ia)
SELECT
id,
first_name,
last_name,
gender,
age
from
user
where id = $1; (there are two tailing spaces here)
Lazy
{
"keaising/textobj-backtick.nvim",
config = function()
require("textobj-backtick").setup({})
end,
},
Default config
require("textobj-backtick").setup({
-- no backticks, no white spaces
inner_trim_key = "i`"
-- no backtick, keep white spaces
-- empty content will be ignore.
inner_all_key = "",
-- all content, include backticks
around_key = "a`"
})
Set following keymap in Neovim.
nnoremap <leader>vv v<Plug>(textobj-backtick-i) :!pg_format<CR>
By <leader>vv
, users can visual select content in backticks and format it with pg_format
const SampleString = `
SELECT
id,
first_name,
last_name,
gender,
age
FROM
user
WHERE
id = $1;
`