How do you set wild card in vim custom mapping?

For example, I want to map a key stroke <Fixed key><Number>to :tabn <Number><CR>. I usually do not use more than 8-9 open tabs, so this will be useful for quickly switching between tabs. How to configure mapping for any record in <Number>? Of course, since there are only 9 possible options, I can simply write them for each of them, but I wanted to know if there is a more reasonable way to do this.

+3
source share
1 answer

Your question is good, but you can already use <number>gtfor this. And I'm afraid there is no way to have an argument-dependent mapping. However, you can do a loop in vimscript that generates your display commands.

Edit: otherwise you can put this in your vimrc:

let i = 1
while i <= 9
  execute 'nnoremap <fixed_key>' . i . ' ' . i . 'gt'
  let i = i + 1
endwhile                                                     
+3
source

Source: https://habr.com/ru/post/1790325/


All Articles