Sublime Text 3 Api to close view?
I'm not sure if I am making the difference between a view and a tab.
Anyway, to close the view: view.close ()
To close the window: win.run_command ('close_window')
If you want to close the window with modified buffers, you can undo those changes by scratching the view as shown below:
for win in sublime.windows():
for view in win.views():
view.set_scratch(True)
win.run_command('close_window')
Hope this helps.
source to share
I found this works in Sublime 2 to close the currently active view in the window:
view.window().run_command('close_file')
It probably works in Sublime 3. I guessed the name of the command just by seeing that the File menu has the options Close Window (command name in the other answer) and Close File.
Doing something like view.window().open_file(view.file_name())
or view.window().focus_view(view)
before the above will probably allow you to close an arbitrary file, not just the one active before the command is executed.
source to share