vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump to an already-open file window instead of opening duplicate buffers?

Answer

:drop {file}

Explanation

When the same file is already open elsewhere, using :edit can create extra navigation friction because you stay in the current window and may lose layout context. :drop solves this by reusing an existing window if that file is already visible, and only opening it normally when it is not. It is a strong default for large multi-window sessions where duplicate views are costly.

How it works

:drop {file}
  • Vim searches for a window already showing {file}
  • If found, focus jumps to that window immediately
  • If not found, Vim opens {file} in the current window (like :edit)

This behavior keeps your window graph cleaner and reduces accidental duplicate edits in split-heavy workflows.

Example

Assume you already have app/services/user.rb open in a right split, but your cursor is currently in another window.

Left window:  app/controllers/users_controller.rb
Right window: app/services/user.rb

From the left window, run:

:drop app/services/user.rb

Instead of opening another copy, Vim jumps to the existing right split that already contains that file.

Tips

  • Use :tab drop {file} for similar behavior at tab scope
  • Pair with :ls and buffer numbers when hunting duplicates
  • If you intentionally need another view of the same file, use :split or :vsplit directly

Next

How do I inspect a register as a list of lines in Vimscript?