Skip to content

Instantly share code, notes, and snippets.

@acken
Created April 23, 2013 10:46
Show Gist options
  • Save acken/5442592 to your computer and use it in GitHub Desktop.
Save acken/5442592 to your computer and use it in GitHub Desktop.
Sublime vim windows navigation
import sublime, sublime_plugin
class VimWindowNavigateLeftCommand(sublime_plugin.WindowCommand):
def run(self):
next = 0
active = self.window.active_group()
if active > 0:
next = active - 1
self.window.focus_group(next)
self.window.active_view().run_command('exit_insert_mode')
class VimWindowNavigateRightCommand(sublime_plugin.WindowCommand):
def run(self):
active = self.window.active_group()
groups = self.window.num_groups()
next = active + 1
if active + 2 > groups:
next = groups - 1
self.window.focus_group(next)
self.window.active_view().run_command('exit_insert_mode')
class VimWindowNavigateUpCommand(sublime_plugin.WindowCommand):
def run(self):
active = self.window.active_group()
groups = self.window.num_groups()
next = 0
if active > 1:
if groups == 4:
next = active - 2
else:
next = active - 1
self.window.focus_group(next)
self.window.active_view().run_command('exit_insert_mode')
class VimWindowNavigateDownCommand(sublime_plugin.WindowCommand):
def run(self):
active = self.window.active_group()
groups = self.window.num_groups()
next = groups - 1
if active < 2:
if groups == 4:
next = active + 2
else:
next = active + 1
self.window.focus_group(next)
self.window.active_view().run_command('exit_insert_mode')
class VimSaveAllAndExitInsertModeCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('save_all')
self.window.active_view().run_command('exit_insert_mode')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment