diff --git a/autotests/src/vimode/keys.cpp b/autotests/src/vimode/keys.cpp --- a/autotests/src/vimode/keys.cpp +++ b/autotests/src/vimode/keys.cpp @@ -590,6 +590,31 @@ // Clear mappings for subsequent tests. clearAllMappings(); + + { + // Test that g and g work as gk and gj (BUG: 418486) + ensureKateViewVisible(); // Needs to be visible in order for virtual lines to make sense. + KateViewConfig::global()->setDynWordWrap(true); + + BeginTest(multiVirtualLineText); + TestPressKey("gjrX"); + const QString expectedAfterVirtualLineDownAndChange = kate_document->text(); + Q_ASSERT_X(expectedAfterVirtualLineDownAndChange.contains("X") && !expectedAfterVirtualLineDownAndChange.startsWith('X'), "Testing g", "gj doesn't seem to have worked correctly!"); + FinishTest(expectedAfterVirtualLineDownAndChange); + + DoTest(multiVirtualLineText, "grX", expectedAfterVirtualLineDownAndChange); + + BeginTest(multiVirtualLineText); + TestPressKey("$gkrX"); + const QString expectedAfterVirtualLineUpAndChange = kate_document->text(); + Q_ASSERT_X(expectedAfterVirtualLineUpAndChange.contains("X") && !expectedAfterVirtualLineUpAndChange.endsWith('X'), "Testing g", "gk doesn't seem to have worked correctly!"); + FinishTest(expectedAfterVirtualLineUpAndChange); + + DoTest(multiVirtualLineText, "$grX", expectedAfterVirtualLineUpAndChange); + + KateViewConfig::global()->setDynWordWrap(false); + } + } void KeysTest::LeaderTests() diff --git a/src/vimode/modes/normalvimode.cpp b/src/vimode/modes/normalvimode.cpp --- a/src/vimode/modes/normalvimode.cpp +++ b/src/vimode/modes/normalvimode.cpp @@ -3636,7 +3636,9 @@ ADDMOTION("M", motionToMiddleLineOfWindow, 0); ADDMOTION("L", motionToLastLineOfWindow, 0); ADDMOTION("gj", motionToNextVisualLine, 0); + ADDMOTION("g", motionToNextVisualLine, 0); ADDMOTION("gk", motionToPrevVisualLine, 0); + ADDMOTION("g", motionToPrevVisualLine, 0); ADDMOTION("(", motionToPreviousSentence, 0); ADDMOTION(")", motionToNextSentence, 0); ADDMOTION("{", motionToBeforeParagraph, 0); diff --git a/src/vimode/modes/visualvimode.cpp b/src/vimode/modes/visualvimode.cpp --- a/src/vimode/modes/visualvimode.cpp +++ b/src/vimode/modes/visualvimode.cpp @@ -360,7 +360,9 @@ ADDMOTION("", motionPageUp, 0); ADDMOTION("", motionPageUp, 0); ADDMOTION("gj", motionToNextVisualLine, 0); + ADDMOTION("g", motionToNextVisualLine, 0); ADDMOTION("gk", motionToPrevVisualLine, 0); + ADDMOTION("g", motionToPrevVisualLine, 0); ADDMOTION("(", motionToPreviousSentence, 0); ADDMOTION(")", motionToNextSentence, 0); ADDMOTION("{", motionToBeforeParagraph, 0);