Custom Macros that Behave Like 't' and 'f'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Custom Macros that Behave Like 't' and 'f'

Jason Franklin

I'm working on a plugin that I believe will be helpful to a great many Vim users.  Right now, I need a method for developing a macro that is entered and then takes a character to operate on as its final component.  This idea is most similar to the way users enter the 't' and 'f' commands in Normal mode.

The closest I've come to this behavior is the following (inspired by reading ":h map-expr"):

nnoremap <expr> \e ':echo "\"' . nr2char(getchar(0)) . '\""' . "\<CR>"
nnoremap <expr> \ee ':echo '"e"'<CR>'

This macro will echo any character that follows '\e' in Normal mode.  When you enter '\e', the macro does not patiently wait as with 't' and 'f', it times out like a standard mapping.

If this is not possible, it would make some sense given the way that normal user mappings behave, but I would greatly appreciate a consistent and reasonable "Vim way" to make this work.

Best to all,

You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit

You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit