I want to use yt<anyChar> for yanking and for jumping, so that cursor moves to the first char before <anyChar>. For backward moving this is working by default (after yT<anyChar> cursor moves to the first char after <anyChar> and I even can use ; and , for additional jumps).

In my Emacs+Evil config I've done it by simply advising evil-yank function:

    (defun evil-yank-after (beg end type register yank-handler)
      (if (= (point) beg)
        (goto-char (1- end))
      (goto-char beg)))

    (advice-add #'evil-yank :after #'evil-yank-after)

In vim I guess approach is totally different?

1 Answer 1


This is not so easy, because you need to get one additional char after the t command. However, I think you can map it using an expression mapping like this:

omap <expr> t 't'.nr2char(getchar())."`]"

This maps the t command to the t, gets one character from the user using getchar() function and then moves the cursor to the last character of the previously yanked or changed command

Note, this is a very simple mapping, that might not work correctly in error cases or some special cases (and probably also brakes the ; and , command), so beware of some unexpected behaviour. (e.g. take a look at my ftimproved plugin for how many special cases you have to consider).

  • Thanks! To restrict this to yanking only I need something like nnoremap <expr> yt 'yt'.nr2char(getchar())."]"`? No better way?
    – A.King
    Jul 2, 2017 at 9:54
  • Is there any analogue of getchar() for variable length string until <CR>? To do the same for /?
    – A.King
    Jul 2, 2017 at 10:18
  • Sure, :h input() Jul 2, 2017 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.