@@ -9,7 +9,7 @@ use helix_core::{
99};
1010
1111use helix_view::{
12− document::Mode,
12+ document::{IndentStyle, Mode},
1313 view::{View, PADDING},
1414 Document, DocumentId, Editor, ViewId,
1515};
@@ -979,6 +979,28 @@ mod cmd {
979979 doc.format(view.id)
980980 }
981981
982+ fn set_indent_style(editor: &mut Editor, args: &[&str], event: PromptEvent) {
983+ use IndentStyle::*;
984+
985+ let style = match args.get(0) {
986+ Some(arg) if "tabs".starts_with(&arg.to_lowercase()) => Some(Tabs),
987+ Some(arg) if arg.len() == 1 => {
988+ let ch = arg.chars().next().unwrap();
989+ if ('1'..='8').contains(&ch) {
990+ Some(Spaces(ch.to_digit(10).unwrap() as u8))
991+ } else {
992+ None
993+ }
994+ }
995+ _ => None,
996+ };
997+
998+ if let Some(s) = style {
999+ let (_, doc) = editor.current();
1000+ doc.indent_style = s;
1001+ }
1002+ }
1003+
9821004 fn earlier(editor: &mut Editor, args: &[&str], event: PromptEvent) {
9831005 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
9841006 Ok(uk) => uk,
@@ -1143,6 +1165,13 @@ mod cmd {
11431165 fun: format,
11441166 completer: None,
11451167 },
1168+ Command {
1169+ name: "indent_style",
1170+ alias: None,
1171+ doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
1172+ fun: set_indent_style,
1173+ completer: None,
1174+ },
11461175 Command {
11471176 name: "earlier",
11481177 alias: Some("ear"),