How to configure Sublime Text 2/3 to use direct Ctrl+Tab order and to create new tabs after the last one?

Sublimetext2Sublimetext3Sublimetext

Sublimetext2 Problem Overview


When I press Ctrl+Tab, Ctrl+Shift+Tab or Ctrl+W the tab I get switched to is not the one just near the one I was on (as I would like to) but to some else. When I press Ctl+N the new tab is created right near the tab I am at while I always want it to be created at the end of the tabs list. How to configure it to achieve the behaviour I desire?

Sublimetext2 Solutions


Solution 1 - Sublimetext2

To achieve the Ctrl+Tab and Ctrl+Shift+Tab behavior you can add the following lines to your sublime-keymap:

{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }

To open sublime-keymap:

  1. click "Preferences"
  2. click "Key Bindings"
  3. You will see two settings file, select a file that named "User"

Solution 2 - Sublimetext2

With the default key bindings, ControlPage Up and ControlPage Down will allow you to move right and left among your open tabs, respectively, in their visual order. (The keybinding solution replicates this functionality using your preferred keys.)

Because the package installer is now included with Sublime Text, it's also straightforward to add the MoveTab extension, which adds the shortcuts ShiftControlPage Up and ShiftControlPage Down to move the current tab within that visual order.

To access the package installer in Sublime Text 3 (in Windows, anyway), type ShiftControlp, then Package Control: Install Package.

Solution 3 - Sublimetext2

You can use a plugin to get the new file behavior you want.

import sublime_plugin

class MyNewFile(sublime_plugin.WindowCommand):
    def run(self):
        window = self.window
        view = window.new_file()
        active_group = window.active_group()
        views_in_group = window.views_in_group(active_group)
        window.set_view_index(view, active_group, len(views_in_group) - 1)

Save the above in Packages/User as <somename>.py. Then use the command my_new_file in your key binding for ctrl+n I wouldn't be surprised if there was aplugin to do this already, but it's pretty simple, so easier to write it yourself, than to search package control :) You can likely lose a plugin to do what you want for ctrl+w also, but you didn't describe the behavior you wanted.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIvanView Question on Stackoverflow
Solution 1 - Sublimetext2MiguelgrazView Answer on Stackoverflow
Solution 2 - Sublimetext2duretteView Answer on Stackoverflow
Solution 3 - Sublimetext2skurodaView Answer on Stackoverflow