Skip to content

Instantly share code, notes, and snippets.

@andlrc
Last active May 7, 2023 20:48
Show Gist options
  • Save andlrc/c4d40e80f7596ae6cbea062e4c3f730a to your computer and use it in GitHub Desktop.
Save andlrc/c4d40e80f7596ae6cbea062e4c3f730a to your computer and use it in GitHub Desktop.
vim9script
# t-f - make it possible to provide a count after 't' and 'f'
# Maintainer: Andreas Louv <andreas@louv.dk>
# Date: 07 May 2023
xnoremap <expr> t v:count > 0 ? 't' : <Sid>TF('t')
xnoremap <expr> f v:count > 0 ? 'f' : <Sid>TF('f')
onoremap <expr> t v:count > 0 ? 't' : <Sid>TF('t')
onoremap <expr> f v:count > 0 ? 'f' : <Sid>TF('f')
nnoremap <expr> t v:count > 0 ? 't' : <Sid>TF('t')
nnoremap <expr> f v:count > 0 ? 'f' : <Sid>TF('f')
def TF(tf: string): string
var char = getcharstr()
var cnt = 1
if char =~ '^[1-9]$'
cnt = str2nr(char)
char = getcharstr()
endif
return $'{cnt}{tf}{char}'
enddef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment