From 9a1d50d9a25360d61776e3a4e9f5680570ddf0f6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 14 Nov 2013 00:20:49 +0000 Subject: [PATCH] deindent now deindent non completely indented lines If indent is 4 spaces, and a line has only 3 leading spaces, they will get removed. a-< can be used to avoid this behaviour. --- README.asciidoc | 4 ++++ src/normal.cc | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index 801aeea9..53c9d917 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -127,6 +127,10 @@ Changes * _>_: indent selected lines * _<_: deindent selected lines + * _alt->_: indent selected lines, including empty lines + * _<_: deindent selected lines + * _alt-<_: deindent selected lines, do not remove incomplete + indent (3 leading spaces when indent is 4) * _|_: pipe each selections through the given external filter program and replace with it's output. diff --git a/src/normal.cc b/src/normal.cc index b837a0f5..fe3476af 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -580,6 +580,7 @@ void indent(Context& context, int) editor.insert(indent, InsertMode::Insert); } +template void deindent(Context& context, int) { CharCount tabstop = context.options()["tabstop"].get(); @@ -605,7 +606,11 @@ void deindent(Context& context, int) else if (c == ' ') ++width; else + { + if (deindent_incomplete and width != 0) + res.emplace_back(line, BufferCoord{line, column-1}); break; + } if (width == indent_width) { res.emplace_back(line, BufferCoord{line, column}); @@ -1027,6 +1032,7 @@ KeyMap keymap = { '<', deindent }, { '>', indent }, { alt('>'), indent }, + { alt('<'), deindent }, { ctrl('i'), jump }, { ctrl('o'), jump },