2

Imaging I'm editing some code, and I found a few words that I would like to paste at the current cursor position elsewhere in the file. I will go to them, yank them, but then how do I return back to the original location to paste them?

3 Answers 3

4

You can use explicit marks with m normal command:

  1. ma -- mark position into register a
  2. goto anywhere
  3. return to the marked position with `a
  • :h mark-motions
  • :h registers
1
  • Thank you, this is what I was after, I will dispense the ticks in a couple of days May 27 at 23:16
3

If you jump to the interesting part with a motion, you could use :h <c-o> to jump back where you were.

Another possible approach is to copy the line with :h :copy / :t, like so:

:/pattern/t.

This will search for the next line matching 'pattern' and copy it (t) under the current line (.).

2

In addition to <C-o>, there is the single-quote and backtick mark: '' and ` go the line and line + column from before the last jump I believe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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