Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
add :wq command
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermooo committed Dec 11, 2011
1 parent 39da544 commit 9d823d4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ex_command_parser.py
Expand Up @@ -76,6 +76,12 @@
invocations=(),
error_on=()
),
# TODO: add invocations
('wq', 'wq'): ex_cmd_data(
command='ex_wq',
invocations=(),
error_on=()
),
('read', 'r'): ex_cmd_data(
command='ex_read_shell_out',
invocations=(
Expand Down
20 changes: 20 additions & 0 deletions ex_commands.py
Expand Up @@ -616,3 +616,23 @@ def run(self, edit, range='.', forced=False, count=1, flags=''):
sublime.status_message("There are unsaved changes!")
return
self.view.window().run_command('exit')


class ExWqCommand(sublime_plugin.TextCommand):
"""Ex command(s): :wq
Write the active buffer and close it.
"""
def run(self, edit, range='.', forced=False):
if forced:
handle_not_implemented()
return

if self.view.is_read_only():
sublime.status_message("Can't write a read-only buffer.")
return
if not self.view.file_name():
sublime.status_message("Can't save a file without name.")
return
self.view.run_command('save')
self.view.window().run_command('close')

0 comments on commit 9d823d4

Please sign in to comment.