I'd like to modify a file at two different places but without having to go from one location to another in the same file. So I learned about windows but it seems they only work by splitting. My screen is too small for working comfortably with a split screen. Is there a way to have two windows on the same file and navigate from one to the other like I navigate buffers ?

If it's not possible, what solution do you recommend ? (Apart from moving one of the function to a different file)

Thanks in advance.

  • 1
    You might be interested in tabbed windows :help tab-page That would let you open the same file in two separate views and flip back and forth between them. gt would let you switch back and forth between the two tabs.
    – Wolf
    Mar 20, 2021 at 16:22
  • 2
    You could also try marks for your use case. Mar 20, 2021 at 17:39
  • @Wolf please make that an answer
    – D. Ben Knoble
    Mar 21, 2021 at 13:25
  • @AndrewHo-Lee please make that an answer
    – D. Ben Knoble
    Mar 21, 2021 at 13:26

2 Answers 2


Vim supports tab views where each tab takes up all of Vim's usable space and you can quickly switch between them. A tab page can be divided into windows, though it sounds like that's exactly what you don't want. There are many tab-related commands. You can learn about them at :help tab-page. On my system I was able to open a second view onto my current buffer by issuing the command :tabnew %. Switching between tabs is as easy as gt to go to the next tab, and gT to go to the previous tab. If they are views onto the same buffer they will both reflect changes there immediately no matter which tab you are doing the editing in. You can scroll them to two different places. Each tab has its own cursor position, but they share marks.


Another option is to use marks. Marks are a way of remembering a position within a file.

To set a mark in a file, use ma to set mark a. To jump back to that mark, use 'a to jump to that line, or `a to jump to that precise position. The lowercase marks a-z are per-file and only remembered as long as that file is in the buffer list. The uppercase marks A-Z are saved in viminfo thus persist between sessions and are global (for example, I have mark V set to the first line of my vimrc and so 'V will take me there and open the file if it isn't already in the buffer list).

For more information: :h mark-motions

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.