diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp --- a/src/document/katedocument.cpp +++ b/src/document/katedocument.cpp @@ -4956,6 +4956,12 @@ for (int line = 0; line < lines(); ++line) { Kate::TextLine textline = plainKateTextLine(line); + // if the cursor is on the end of this line, don't trim trailing spaces + if (m_activeView->cursorPosition().line() == line && + m_activeView->cursorPosition().column() == textline.data()->length()) { + continue; + } + // remove trailing spaces in entire document, remove = 2 // remove trailing spaces of touched lines, remove = 1 // remove trailing spaces of lines saved on disk, remove = 1