diff --git a/examples/config/pyvimrc b/examples/config/pyvimrc index 76aad5d..beb191f 100644 --- a/examples/config/pyvimrc +++ b/examples/config/pyvimrc @@ -31,6 +31,7 @@ def configure(editor): # Expand tab. (Pressing Tab will insert spaces.) editor.expand_tab = True # (:set expandtab) editor.tabstop = 4 # (:set tabstop=4) + editor.shiftwidth = 4 # (:set shiftwidth=4) # Scroll offset (:set scrolloff) editor.scroll_offset = 2 diff --git a/pyvim/commands/commands.py b/pyvim/commands/commands.py index ae4d781..fca5299 100644 --- a/pyvim/commands/commands.py +++ b/pyvim/commands/commands.py @@ -544,6 +544,25 @@ def tab_stop(editor, value): editor.show_message('Number required after =') +@set_cmd('shiftwidth', accepts_value=True) +@set_cmd('sw', accepts_value=True) +def shift_width(editor, value): + """ + Set shiftwidth. + """ + if value is None: + editor.show_message('shiftwidth=%i' % editor.shiftwidth) + else: + try: + value = int(value) + if value > 0: + editor.shiftwidth = value + else: + editor.show_message('Argument must be positive') + except ValueError: + editor.show_message('Number required after =') + + @set_cmd('scrolloff', accepts_value=True) @set_cmd('so', accepts_value=True) def set_scroll_offset(editor, value): diff --git a/pyvim/editor.py b/pyvim/editor.py index d652be2..8cfb337 100644 --- a/pyvim/editor.py +++ b/pyvim/editor.py @@ -60,6 +60,7 @@ def __init__(self, config_directory='~/.pyvim', input=None, output=None): self.show_wildmenu = True self.expand_tab = True # Insect spaces instead of tab characters. self.tabstop = 4 # Number of spaces that a tab character represents. + self.shiftwidth = 4 # Number of spaces at indent/unindent self.incsearch = True # Show matches while typing search string. self.ignore_case = False # Ignore case while searching. self.enable_mouse_support = False @@ -266,6 +267,7 @@ def show_set_all(self): "wildmenu": self.show_wildmenu, "expandtab": self.expand_tab, "tabstop": self.tabstop, + "shiftwidth": self.shiftwidth, "scrolloff": self.scroll_offset, "incsearch": self.incsearch, "ignorecase": self.ignore_case,