diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 29f8c323d1fb0197d084849673c096f10fb9d1fd..087d225207f76bf440fe9800f54e6d0a6fb83d01 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -384,6 +384,9 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
         return;
     }
 
+    if (m_visualMode != NoVisualMode)
+        m_marks['>'] = m_tc.position();
+
     if (m_submode == ChangeSubMode) {
         if (!dotCommand.isEmpty())
             m_dotCommand = "c" + dotCommand;
@@ -615,10 +618,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
     } else if (key == ':') {
         m_mode = ExMode;
         m_commandBuffer.clear();
-        if (m_visualMode != NoVisualMode) {
+        if (m_visualMode != NoVisualMode)
             m_commandBuffer = "'<,'>";
-            leaveVisualMode();
-        }
         m_commandHistory.append(QString());
         m_commandHistoryIndex = m_commandHistory.size() - 1;
         updateMiniBuffer();
@@ -640,7 +641,6 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
         m_submode = FilterSubMode;
     } else if (key == '!' && m_visualMode == VisualLineMode) {
         m_mode = ExMode;
-        m_marks['>'] = m_tc.position();
         m_commandBuffer = "'<,'>!";
         m_commandHistory.append(QString());
         m_commandHistoryIndex = m_commandHistory.size() - 1;
@@ -1021,6 +1021,7 @@ bool FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text
             m_commandHistory.takeLast();
             m_commandHistory.append(m_commandBuffer);
             handleExCommand(m_commandBuffer);
+            leaveVisualMode();
         }
     } else if (key == Key_Return && isSearchMode()) {
         if (!m_commandBuffer.isEmpty()) {
@@ -1140,7 +1141,6 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
     if (cmd.startsWith("%"))
         cmd = "1,$" + cmd.mid(1);
     
-    m_marks['>'] = m_tc.position();
     int beginLine = -1;
     int endLine = -1;