GithubHelp home page GithubHelp logo

ccampbell / sublime-goto-window Goto Github PK

View Code? Open in Web Editor NEW
41.0 4.0 12.0 11 KB

Sublime Text plugin to quickly switch to any open window using a keyboard command

License: MIT License

Python 100.00%
sublime sublime-package window-manager sublime-text

sublime-goto-window's Introduction

Sublime Goto Window

This package allows you to change between open windows in Sublime Text using a prompt. It is useful if you have a lot of windows open with different projects in them and you want to switch without having to press command ~ over and over again.

To Install

If you are using Sublime Package Control you can press command+shift+p. Then select Package Control: Install Package and choose GotoWindow.

Another option is running the following command (this is the OS X version):

cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
git clone [email protected]:ccampbell/sublime-goto-window.git GotoWindow

Linux dependencies

This plugin depends on wmctrl being installed on your system. On Debian-based operating systems (such as Ubuntu), you can get it using apt-get install wmctrl.

Usage

The default keybinding is

super + shift + o

After that you will see a menu that looks like this containing all your open windows in Sublime Text:

hyog

Select an item and that's it!

Note

There is a bug that prevents this from actually working natively using Sublime Text APIs. See sublimehq/sublime_text#444 for more information.

I haven't been able to test it on Windows, but there are workarounds in place that seem to work on OS X and Linux.

sublime-goto-window's People

Contributors

ccampbell avatar deborasetton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sublime-goto-window's Issues

display sublime project name

I'd like the option to display the project name of the window, if a project is open instead of just files. Thanks for the great plugin =)

Switching with numbers?

Question/Feature Request:

Would it be possible to switch the window using numbers after pressing cmd+shift+o. Is something like that even possible with that pull down menu that sublime offers

Just wanted to say thanks!

This plugin is really saving my sanity! As a product manager and coder, I always have several Sublime windows up at any one time. This is REALLY saving my bacon. Thanks so much!

Doesn't work on Linux (suggestion: use wmctrl)

Hi,

I just installed this plugin, and it works great up until the part where I select the window I'd like to focus, and then it doesn't do anything (the selected window is not activated, Sublime just stays right where it was before).

I tracked down the issue to the focus function. If I run the code of that function in Sublime Console, it also has no effect. Also, this doesn't seem to be a bug similar to the OS X one, because if I Alt-Tab out of Sublime and back again, the old window is still the active one.

I have found a very simple workaround which seems to work well: delegate the actual focusing of a window to the underlying window manager, wmctrl.

Would you be instereted in a patch for this? If so, I'd be happy to submit one for review.

Cheers,
Débora.

Window not switching in MacOS Big Sur 11.1 (Sublime 3.2.2)

Hey everyone!

This may be useless now that I see that it's been a while since this repo was last updated, but this package isn't working on my end right now (worked beautifully for years).

I'm on Sublime 3.2.2. When called, the input shows up with all open windows available and I can write or select the window I want to go to. Done that, the current window loses focus, but the selected window doesn't come up.

Am I the only one seeing this?

I'm in MacOS Big Sur, version 11.1, if that matters.

Thanks!

Goto Window only works for windows with project folders

Goto Window only works for windows with project folders

If a window has no project associated with it or if no folders have been added to the project, then Goto Window does not list the window at all.

The problem arises in the method below, since only windows for which window.folders() is not an empty list get added.

def _get_folders(self):
    folders = []
    home = os.getenv('HOME')
    for i, window in enumerate(sublime.windows()):
        for folder in window.folders():
            if folder.startswith(home):
                folder = folder.replace(home, '~')

            folders.append((folder, i))

When a window has no project or a project which has not had folders added to it, then window.folders() returns an empty list [].

Also the plugin uses the folder name instead of the project name - and even worse results in the final project folder being used as the text displayed in the overlay. For example if the project file looks like this:

{
    "folders":
    [
        {
            "path": "/path/to/MyPlugin"
            "path": "/path/to/icons"
        }
    ]
}

Then the window's name in the overlay will be 'icons'.

Instead I suggest you use the Window class project_file_name() method to get the actual project name, with something like the code below, which is the established way plugin developers get the project name, and will give you the same thing as what ST displays in the title bar of its windows after the file path.

# e.g. "/path/to/Projects/My Project Name.sublime-project" --> "My Project Name"

project_file_path = window.project_file_name()
project_file_name = os.path.basename(project_file_path)
project_name = os.path.splitext(project_file_name)[0]

Then there would be no need to iterate through window.folders() at all.

If there is no project at all in the window then window.project_file_name() will return None. In these cases then instead of using the project name in the overlay I suggest you use the buffer name of the buffer which is in the active view of the window.

active_view_path = window.active_view().file_name()
active_view_filename = os.path.basename(active_view_path)

# Watch out as `window.active_view().file_name()` will return None
# for "untitled" buffers, in which case you could just use "untitled".

I hope this helps.

Windows 7 ST3

Hi there,

Was just thinking about suggesting this feature, but then found your plug-in. 👍

I installed, and although it took a bit to find I had to add in the keystroke from the file in the repository, but then when I ran it, the following error was produced:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 535, in run_
return self.run()
File "GotoWindow in C:\Users\username\AppData\Roaming\Sublime Text 3\Installed Packages\GotoWindow.sublime-package", line 9, in run
File "GotoWindow in C:\Users\username\AppData\Roaming\Sublime Text 3\Installed Packages\GotoWindow.sublime-package", line 91, in _get_folders
TypeError: startswith first arg must be str or a tuple of str, not NoneType

Thoughts?

Thanks.

-Keith

shortcut trigger an error in the console

here is the log:
return self.run()
File "GotoWindow in D:\apps\SublimeText\Data\Installed Packages\GotoWindow.sublime-package", line 9, in run
File "GotoWindow in D:\apps\SublimeText\Data\Installed Packages\GotoWindow.sublime-package", line 91, in _get_folders
TypeError: startswith first arg must be str or a tuple of str, not NoneType

Windows 10 x64, Python 3.3, SublimeText 3
(python may be the problem here)

To close the window

Feature Request:

Would it be possible to close the Window from the goto pop up window itself. When I have multiple projects, and if I would like to close a few..

cmd+shift+o -> then with ctrl key pressed when I select a window, that window shall be closed.

Would such a feature be possible?

Doesn't work with multiple windows that have the same title

My workflow involves having several windows with the same title open (because they all have a different directory with the same name open). When I press win+shift+o, I see the list of windows, all with the same title (but with different paths in smaller text underneath). However, no matter which window I select, I always switch to the same window, always. I suspect this happens because of some name collision inside the extension.

Can't use it on Wnidows 10 with Sublime Text 3

Hlelo,

When I try ot use it on Windows 10 with SublimeText 3 build 3125 µI have this error message:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 797, in run_
return self.run()
File "C:\Users\herve.t.AVRILLE\AppData\Roaming\Sublime Text 3\Packages\GotoWindow\GotoWindow.py", line 9, in run
folders = self._get_folders()
File "C:\Users\herve.t.AVRILLE\AppData\Roaming\Sublime Text 3\Packages\GotoWindow\GotoWindow.py", line 116, in _get_folders
if folder.startswith(home):
TypeError: startswith first arg must be str or a tuple of str, not NoneType

Catalina 10.15.7, dual screen, only works on main screen

Hi,

I'm using 1.0.7 and it seems that the GotoWindow function does not work correctly with multiple screens.

When using it on my main screen it works fine, but if the window is on the secondary screen, it does not focus correctly.

I have figured out that it focuses the correct window in sublime, but the trick via applescript always focuses Sublime Text on the main screen.

1.5 seconds to switch on Mac?

First, thank you for such an amazing plugin! I was looking for a better way to manage Sublime windows and this hit the spot. I just discovered it yesterday and I am loving it.

I have about 10-15 windows open on my macbook and I find that switching happens after a 1.5 second delay. I am aware this is not that long, but I am used to windows switching instantly. Is this the case for most people, switching taking 1.5 seconds? Also do you know why this might be or if there is a way to configure it?

I am happy to take a look at the code as well.

Is it working on Wayland Ubuntu 22.04?

This is a freaking awesome idea and I'm so happy that I found it.
But sadly it doesn't work :/ The action is able to list sublime text windows, but it won't change the focus once I select one.

I debugged a bit with wmctrl, and running wmctrl doesn't show ANY sublime text window (shows my Chrome, also doesn't show the gnome-terminal app) so I figure that's the problem.

I might continue debugging it, posting here for visibility...

Sublime build: 4143
Ubuntu 22.04
Wayland
Gnome 42.5

Does not work in full screen mode

Thanks for creating this! Does not work in full screen mode, however. The option to select additional windows still comes up, but when those windows are selected the focus does not change.

To replicate:

  1. Open two windows in sublime text (e.g. $ cd /project && subl .)
  2. Enter full screen mode on one or both
  3. Attempt to switch between windows

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.