Skip to content

Commit

Permalink
text objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ediw8311xht committed Sep 22, 2024
1 parent e5a6d7d commit 98addf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions nvim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ colorscheme pop-punk

lua require('functions')
lua require('mappings')
lua require('textobjects')

:call CorrectColors()

Expand Down
13 changes: 13 additions & 0 deletions nvim/lua/textobjects.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

-- from: https://thevaluable.dev/vim-create-text-objects/
local function basic_text_objects(chars)
for _,char in ipairs(chars) do
for _,mode in ipairs({ 'x', 'o' }) do
vim.api.nvim_set_keymap(mode, "i" .. char, string.format(':<C-u>silent! normal! f%sF%slvt%s<CR>', char, char, char), { noremap = true, silent = true })
vim.api.nvim_set_keymap(mode, "a" .. char, string.format(':<C-u>silent! normal! f%sF%svf%s<CR>', char, char, char), { noremap = true, silent = true })
end
end
end

local chars = { '_', '.', ':', ',', ';', '|', '/', '\\', '*', '+', '%', '`', '?', '$' }
basic_text_objects(chars)

0 comments on commit 98addf2

Please sign in to comment.