Sublime Forum

Close duplicate views in the same file

#1

I open most of my files using ctrl-p and search. This results in having the same file open multiple times which after a while becomes a problem. Is there a way I can automatically close all duplicate views to the same file?

1 Like

#2

I cannot reproduce this problem. When I attempt to open a file with is already open by Ctrl+P, it restaures the first opened view.

What Sublime Text build are you using?

0 Likes

#3

You will need to use ctrl+P in a different view. Open 2 views (alt-shift-2 I think), open the file in one view, then focus on the other view and use ctrl-p for the same file. I am not sure if project setup is needed, I suspect not.

0 Likes

#4

It is not 2 views, but groups of views. This is the standard Sublime Text behavior, but you can override it with a package.

  1. http://docs.sublimetext.info/en/latest/file_management/file_navigation.html#panes
  2. http://www.macdrifter.com/2012/07/sublime-text-working-with-multiple-panes.html

You can write a Sublime Text package to check whether there is a file currently open in some group of views. Then if it is, cancel the opening and focus on the view.

See:

  1. https://www.sublimetext.com/docs/3/api_reference.html
  2. http://www.sublimetext.com/docs/plugin-basics
  3. http://docs.sublimetext.info/en/latest/extensibility/plugins.html
0 Likes

#5

I was hoping that there was a package already out there for this. Probably I have to write it on my own then

Cheers

0 Likes

#6

By the way, this was hardly constructive. You just send me links to plugin development and did not tackle the issue at hand at all.

0 Likes

#7

this may help to find the clones

then it should just be a matter of creating a command that will iterate through them and close all the clones (but leaving the first one open) and binding a key to that

2 Likes

#8

@kingkeith Thanks this is to the point!

0 Likes