diff --git a/PSReadLine/KeyBindings.cs b/PSReadLine/KeyBindings.cs
index 16cf72b..6cee7ea 100644
--- a/PSReadLine/KeyBindings.cs
+++ b/PSReadLine/KeyBindings.cs
@@ -398,6 +398,7 @@ namespace Microsoft.PowerShell
case nameof(Cut):
case nameof(DeleteChar):
case nameof(DeleteCharOrExit):
+ case nameof(DeleteEndOfBuffer):
case nameof(DeleteEndOfWord):
case nameof(DeleteLine):
case nameof(DeleteLineToFirstChar):
diff --git a/PSReadLine/KeyBindings.vi.cs b/PSReadLine/KeyBindings.vi.cs
index dca19af..867bdbf 100644
--- a/PSReadLine/KeyBindings.vi.cs
+++ b/PSReadLine/KeyBindings.vi.cs
@@ -226,6 +226,7 @@ namespace Microsoft.PowerShell
{ Keys.W, MakeKeyHandler( DeleteWord, "DeleteWord") },
{ Keys.ucW, MakeKeyHandler( ViDeleteGlob, "ViDeleteGlob") },
{ Keys.E, MakeKeyHandler( DeleteEndOfWord, "DeleteEndOfWord") },
+ { Keys.ucG, MakeKeyHandler( DeleteEndOfBuffer, "DeleteEndOfBuffer") },
{ Keys.ucE, MakeKeyHandler( ViDeleteEndOfGlob, "ViDeleteEndOfGlob") },
{ Keys.H, MakeKeyHandler( BackwardDeleteChar, "BackwardDeleteChar") },
{ Keys.L, MakeKeyHandler( DeleteChar, "DeleteChar") },
diff --git a/PSReadLine/PSReadLineResources.resx b/PSReadLine/PSReadLineResources.resx
index 96ceaf5..dcc052a 100644
--- a/PSReadLine/PSReadLineResources.resx
+++ b/PSReadLine/PSReadLineResources.resx
@@ -802,4 +802,7 @@ Or not saving history with:
The predictive suggestion feature cannot be enabled because the console output doesn't support virtual terminal processing or it's redirected.
+
+ Delete the current logical line and up to the end of the multiline buffer
+
diff --git a/PSReadLine/ReadLine.vi.cs b/PSReadLine/ReadLine.vi.cs
index 230718d..4d304a7 100644
--- a/PSReadLine/ReadLine.vi.cs
+++ b/PSReadLine/ReadLine.vi.cs
@@ -782,6 +782,24 @@ namespace Microsoft.PowerShell
return deletePosition;
}
+ ///
+ /// Deletes from the current logical line to the end of the buffer.
+ ///
+ public static void DeleteEndOfBuffer(ConsoleKeyInfo? key = null, object arg = null)
+ {
+ var lineIndex = _singleton.GetLogicalLineNumber() - 1;
+ var lineCount = _singleton.GetLogicalLineCount() - lineIndex;
+
+ DeleteLineImpl(lineIndex, lineCount);
+
+ // move the cursor to the beginning of the previous line
+ var previousLineIndex = Math.Max(0, lineIndex - 1);
+ var newPosition = GetBeginningOfNthLinePos(previousLineIndex);
+
+ _singleton._current = newPosition;
+ _singleton.Render();
+ }
+
///
/// Deletes the previous word.
///
diff --git a/test/BasicEditingTest.VI.cs b/test/BasicEditingTest.VI.cs
index e25ef0d..0beacfb 100644
--- a/test/BasicEditingTest.VI.cs
+++ b/test/BasicEditingTest.VI.cs
@@ -469,6 +469,26 @@ namespace Test
));
}
+ [SkippableFact]
+ public void ViDeleteToEndOfBuffer()
+ {
+ TestSetup(KeyMode.Vi);
+
+ Test("\"-\"", Keys(
+ _.DQuote, "-", _.Enter,
+ "one", _.Enter,
+ "two", _.Enter,
+ "three", _.Enter,
+ _.DQuote, _.Escape,
+ "kkkl", // go to the 'ne' portion of "one"
+ // delete to the end of the next line
+ "dG",
+ CheckThat(() => AssertCursorLeftIs(0)),
+ // terminate the buffer
+ _.A, _.DQuote
+ ));
+ }
+
[SkippableFact]
public void ViGlobDelete()
{