Skip to content

Commit

Permalink
add editor.shiftwidth
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Aug 10, 2024
1 parent 88675e4 commit 6c57539
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/config/pyvimrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pyvim/commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions pyvim/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6c57539

Please sign in to comment.