azabiong / vim-highlighter

Highlight words and expressions
MIT License
226 stars 9 forks source link

How to programmatically set HiSetSL and HiSet (visual mode) #26

Closed krzkrzkrz closed 11 months ago

krzkrzkrz commented 12 months ago

I might have missed reading something in the help file.

But if vim.keymap.set('n', 'tt', ':Hi+<CR>') allows me to highlight a set (the equivalent of HiSet)

How do I set a keymap for HiSetSL?

Similarly, how do you programmatically set keymaps for HiSet and HiSetSL in visual select mode?

azabiong commented 12 months ago

Ah, you can use :Hi+% command for HiSetSL function.

krzkrzkrz commented 12 months ago

Hi, and what about for visual select mode?

I was thinking vim.keymap.set('v', 'tw', ':Hi+x<CR>') and vim.keymap.set('v', 'tw', ':Hi+x%<CR>')? Or am I missing something?

azabiong commented 12 months ago

You can use the same key for both normal and visual modes.

So, how about assigning tt to both :Hi+and :Hi+x commands, and tw to :Hi+% and :Hi+x% ?

Here 'x' means visual mode.

krzkrzkrz commented 12 months ago

Hmmmm that works, maybe I did not explain well. I want to highlight part of a word/selection in visual mode

azabiong commented 12 months ago

I'm glad it's working now. May I ask a question that in which cases you would prefer direct mapping instead of using predefined variables? Wouldn't it be simpler to assign keys to predefined variables something like vim.g.HiSet = 'tt'

krzkrzkrz commented 11 months ago

Ahh, that works better actually. Thank you for pointing that out. Let me close the issue for now