[frameworks/ktexteditor] /: vi-mode: Add Ctrl-A command to insert mode

Christoph Cullmann <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b886a2d344102d9b33de18a91b339f70aa4aa045 by Christoph Cullmann, on behalf of Ismael Asensio.
Committed on 20/07/2026 at 22:41.
Pushed by cullmann into branch 'master'.

vi-mode: Add Ctrl-A command to insert mode

This command pastes the last inserted text.
It is equivalent to `Ctrl-R.`

M  +5    -0    autotests/src/vimode/modes.cpp
M  +4    -0    src/vimode/modes/insertvimode.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/b886a2d344102d9b33de18a91b339f70aa4aa045

diff --git a/autotests/src/vimode/modes.cpp b/autotests/src/vimode/modes.cpp
index 2449c3087..d8ccf44e3 100644
--- a/autotests/src/vimode/modes.cpp
+++ b/autotests/src/vimode/modes.cpp
@@ -1117,6 +1117,11 @@ void ModesTest::InsertKeysTests()
     DoTest("bar\nbaz", "vj\"byjlla\\ctrl-rboo", "bar\nbazbar\nboo");
     DoTest("Hello", "0yei\\ctrl-r\"", "HelloHello");
 
+    // Ctrl-A
+    DoTest("foo", "Abar\\escabaz\\ctrl-a", "foobarbazbar");
+    DoTest("foo", "A\\enterbar\\escabaz\\ctrl-a", "foo\nbarbaz\nbar");
+    DoTest("foo", "A\\enterbar\\escabaz\\ctrl-a\\ctrl-a", "foo\nbarbaz\nbar\nbar");
+
     // Ctrl-O
     DoTest("foo bar baz", "3li\\ctrl-od2w", "foobaz");
     DoTest("foo bar baz", "3li\\ctrl-od2w\\ctrl-w", "baz");
diff --git a/src/vimode/modes/insertvimode.cpp b/src/vimode/modes/insertvimode.cpp
index dd5374904..ace5bdc8d 100644
--- a/src/vimode/modes/insertvimode.cpp
+++ b/src/vimode/modes/insertvimode.cpp
@@ -392,6 +392,10 @@ bool InsertViMode::handleKeypress(const QKeyEvent *e)
                     m_viInputModeManager->completionReplayer()->replay();
                 }
                 return true;
+            case Qt::Key_A:
+                m_register = InsertStoppedRegister;
+                commandInsertContentOfRegister();
+                return true;
             case Qt::Key_C:
                 leaveInsertMode(true);
                 return true;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.