Skip to content

keaising/textobj-backtick.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

textobj-backtick.nvim

Textobj for backtick, this plugin is better than default behavior in Neovim that it allows user to choose content in multilines.

1. Example

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;  `

1.1 Trim backticks and white spaces around

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;

1.2 Keep all backticks and white spaces around

Keymap: a`

Complex keymap: <Plug>(textobj-backtick-a)

`  SELECT
  id,
  first_name,
  last_name,
  gender,
  age
from
  user
where id = $1;  `

1.3 Trim backticks only, keep all white spaces around

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)

2. Install

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`"
})

3. Use case

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;
`

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages