Kate and KWrite both don't show all \n characters. Problems appear to be next to where there are empty lines.

The problem isn't just in the highlighting itself. Wrong number of matches are found. Search and replace doesn't replace all \n characters.

Searching for \r doesn't find anything. If I place the cursor at the beginning of, say, line 7 and press delete and then enter, the search works.

Is it possible that other characters, besides \n and \r are used for newlines? The file was created as UTF-8 and only opened with Kate as UTF-8.


I understand that posting a picture of text is discouraged, but I can't show the highlighting without the screenshot.

This is of utmost importance to me, because I use Kate's search and replace feature to quickly format big documents, e.g. for StackExchange.

I run up-to-date Fedora 24 with KDE.

Kate version 16.04.3.


KDE Frameworks 5.24.0

Qt 5.6.1 (built against 5.6.1)

The xcb windowing system

Update I think I found a way to reproduce the bug.

  • Open the file. It has to have empty lines in order to work.
  • Search for \n. It should work correctly.
  • Replace \n with \na. Other replacements work as well.
  • Search for \n. It should still work correctly.
  • Undo the change (CTRL + z).
  • Search for \n. It should work incorrectly now, skipping newlines that are before or after an empty line.
  • Reload the file (F5). It should work correctly.

If I save the file on step 5 (the undo), the bug still works. Examining the file with xxd after the save on step 5 and after step 7 (the reload) gives identical outputs. So I guess Kate doesn't change the file or its encoding in any step, but somehow manages to screw up the search.

  • Perhaps you have trailing blanks on the lines, so that the highlighted \n is simply off-screen. – Thomas Dickey Jul 31 '16 at 14:06
  • @ThomasDickey No, I've set to show trailing spaces. – iJustWantVolume Jul 31 '16 at 17:38
  • You could examine the file using xxd or od, to see if there are any odd characters. In a quick check, Kate with Fedora24 seems to handle the case you ask about (its syntax highlighting is a different matter). – Thomas Dickey Jul 31 '16 at 19:51
  • @ThomasDickey Today after OS restart it worked correctly with the same file. I replaced \n with \na and then pressed CTRL + z. Then I got similar issues with the highlighting. It didn't work with lines near empty lines. Then I reloaded the file (F5) and it worked correctly. Can you reproduce the bug that way? – iJustWantVolume Aug 1 '16 at 8:54
  • 1
    yes, I can reproduce this (after undoing, it no longer matches on empty lines). – Thomas Dickey Aug 1 '16 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.