diff --git a/data/geany.glade b/data/geany.glade index 5a6439de67..18f03f44e9 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -3293,6 +3293,22 @@ 1 + + + _Backspace key unindents + True + True + False + With the cursor in the indentation, pressing backspace unindents instead of deleting one character + True + True + + + False + False + 2 + + diff --git a/doc/geany.txt b/doc/geany.txt index 5612b9558a..6abad43244 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -2176,6 +2176,11 @@ Tab key indents unindent, but this preference allows the tab key to have different meanings in different contexts - e.g. for snippet completion. +Backspace key unindents + If set, pressing backspace while the cursor is in leading whitespace + will reduce the indentation level, unless the indentation mode is tabs. + Otherwise, the backspace key will delete the character before the cursor. + Editor Completions preferences ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/editor.c b/src/editor.c index 9114740e04..dc6b229e54 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4646,7 +4646,7 @@ void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width) SSM(sci, SCI_SETINDENT, width, 0); /* remove indent spaces on backspace, if using any spaces to indent */ - SSM(sci, SCI_SETBACKSPACEUNINDENTS, type != GEANY_INDENT_TYPE_TABS, 0); + SSM(sci, SCI_SETBACKSPACEUNINDENTS, editor_prefs.backspace_unindent && (type != GEANY_INDENT_TYPE_TABS), 0); } diff --git a/src/editor.h b/src/editor.h index f3e63e7060..c38bb6c329 100644 --- a/src/editor.h +++ b/src/editor.h @@ -115,6 +115,7 @@ typedef struct GeanyEditorPrefs gboolean unfold_all_children; gboolean disable_dnd; gboolean use_tab_to_indent; /* makes tab key indent instead of insert a tab char */ + gboolean backspace_unindent; /* makes backspace char unindent instead of deleting one char */ gboolean smart_home_key; gboolean newline_strip; gboolean auto_complete_symbols; diff --git a/src/keyfile.c b/src/keyfile.c index f4254f42c3..0ab1632a21 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -255,6 +255,8 @@ static void init_pref_groups(void) "detect_indent_width", FALSE, "check_detect_indent_width"); stash_group_add_toggle_button(group, &editor_prefs.use_tab_to_indent, "use_tab_to_indent", TRUE, "check_tab_key_indents"); + stash_group_add_toggle_button(group, &editor_prefs.backspace_unindent, + "backspace_unindent", TRUE, "check_backspace_unindent"); stash_group_add_spin_button_integer(group, &editor_prefs.indentation->width, "pref_editor_tab_width", 4, "spin_indent_width"); stash_group_add_combo_box(group, (gint*)(void*)&editor_prefs.indentation->auto_indent_mode,