Vim – how to go back to last edited line/context

Sometimes we are editing a certain section of code in vi and then navigate to different section for reference. It is tedious to come back to the section we are editing. Here is a quick trick to come back to same section we were editing earlier.

  1. First undo the last change (temporarily). This will bring us to the section we did the last edit.

    [ESC] + u
    
  2. Now redo the last undo. This will bring back to original state of the file. but the vi cursor is at the last edited locaiton.

    [ESC] + [CTR] + r
    
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments