DEV Community

Patrick Walters
Patrick Walters

Posted on

Using :wq in Sublime Text 3

I wanted to add proper :wq to Sublime Text 3 but did not like the existing solutions as they significantly changed my Sublime Text experience.

I used Edit Command Palette installed through Install Package command. Then added the following commands for my user -

[
    {
        "caption": ":q - Close",
        "command": "close"
    },
    {
        "caption": ":wq - Save and Close",
        "command": "save_and_close"
      }
]

For the second command (save and close) I had to create a custom plugin. To do this click Tools > Developer > New Plugin and create this snippet of python as a plugin -

import sublime
import sublime_plugin


class SaveAndClose(sublime_plugin.TextCommand):
  def run(self, edit):
    self.view.run_command('save')
    self.view.window().run_command('close')

And it works after that!

Top comments (0)