Pressing enter adds a space instead of a line break when adding cards

I use ANKI on my Windows PC to add new cards to my decks. I have found after a while of adding new cards, I will go to press enter to add a line break, or if creating a bullet point list, but instead of adding a line break it inserts a space instead. The only way I have found to rectify this is to close the “Add” window completely, and later edit the cards in the “Browse” window to insert the line breaks where I needed them to be. This is inconvenient because I often add cards in bulk, with specific colour formatting and specific tags, and it is quite annoying to have to set those up each time I have to re-open the “Add” window.

I have found that this above problem occurs at the same time as another problem when typing in a box in the “Add” window, where the program stops adding automatic line breaks if a word is too long to fit on the end of a line. Usually, if I am typing at the end of a line and the word is too long to fit on that line, the word will automatically go to the next line as I type. Instead, if the box has the line break problem, the word at the end of the line will get cut off midway through the word, with the remainder of the word continuing on the next line. It’s as if the program starts treating the sentences I type as an extremely long word, despite the spaces in between each word. This is annoying as well because I like to review my cards on AnkiWeb on my phone and iPad sometimes, meaning the different screen sizes means that random words get cut off midway if they happen to be near the end of a line. The only way I have found to rectify this is to completely retype the card in “Browse” mode so that the program recognises the separate words, because even copying and pasting the content does not work, so often I don’t even bother. This is more of an aesthetic inconvenience, rather than a problem that is actually taking up time, unlike not being able to insert line breaks.

When I start to add cards, line breaks work as normal, but I have found this problem will start to occur without fail if I start adding cards for long enough. Sometimes it’s after adding 2 cards, sometimes it’s after adding 10 or 20, with no noticeable pattern. I only ever use Basic and Cloze cards (and also Image Occlusion, but this problem doesn’t apply here), and noticed that often this problem tends to only happen with either the top box (Front/Text field) or bottom box (Back/Extra field) at a given time, so another way to get around the problem that I’ve tried is to type out what I need in the box that is functioning normally, then cut and paste the content into the problematic box. However I have found that if I continue adding cards, the problem will eventually start happening to both boxes, forcing me to close the “Add” window and reopen it.

I have made sure to update my Anki to the latest version, and the problem still persists. I’ve also only seen one other person ask about this on the forum, but I could not find a working solution and the topic has since closed, so this is my next step on trying to find a solution to the problem, as it is quite annoying.


Both of these issues sound like the result of hidden HTML in the fields of your Add note window. Have you looked at the HTML view when this starts happening (or even before it starts happening)?

You can open that by clicking < > above the field, or the shortcut is Ctrl Shift X. If you have notes like in your screenshot that you haven’t fixed yet, I’d be interested to know what’s in the HTML view of those. [When you post it, put it in a code-/preformatted-text-block by clicking </> in the editing bar above, so the site doesn’t eat it up.]

When you add notes, it would be a good idea for you to keep the HTML view of the fields open. You don’t need to do your editing in that view, but it would be a good idea if you open it when you open the window, and watch for changes.

Finding what remnant of HTML is causing the issue is only half the problem though. There’s still the matter of how that HTML got there. I can think of a few possibilities –

  1. This suggests to me that you’re using sticky/pinned fields when you’re doing your adding. Are you? It’s possible you’re leaving something behind as you make changes from note-to-note.

  2. Have you tried running Anki in safe mode [Troubleshooting Checklist #2] to make sure an add-on isn’t involved in this?

  3. If Anki is somehow adding random HTML to the field, or not fully clearing out the field after adding a note, the first thing we’ll need to know is your complete version information. Go to Help > About – click Copy Debug Info – paste the entire thing here when you respond.

Was that this post – Problem - Pressing enter adds a space ? It helps to have a link to the other issue.

1 Like

Hi, thank you for your reply, and sorry about my delay in replying, had a busy couple of weeks. Just to preface this is my first experience dealing with HTML, so hopefully this all makes sense. So the code for the screenshotted card in my original post shows as follows:

<span style="color: rgb(170, 85, 0);">Incubation&nbsp;period&nbsp;for&nbsp;cutaneous&nbsp;leishmaniasis&nbsp;from&nbsp;sandfly&nbsp;bite&nbsp;to&nbsp;lesion&nbsp;development?</span>

I will also add a screenshot of what this looks like in browse mode just in case.

After reading your reply, I did try adding some cards with the HTML view open. When working as normal, a &nbsp; would be added when I made a space after a word, but it would automatically be removed when I started typing my next word, leaving an empty space there in the HTML view. I then found that the problem of the enter button adding a space instead of a line break tends to occur when &nbsp; is put between each of my words, but stays there when typing further words, as opposed to leaving an empty space. I also found that when I pressed the enter button while this was happening, it would insert a &nbsp; as well, instead of a line break, and any space/line break I tried to add would just become an &nbsp; and I can even create a long string of them. Put a screenshot of an example of this happening, on the card I was adding about safeguarding. I also typed out the contents of the Back field onto the Front field for comparison. I also found that even after copying and pasting the contents from the normal Front field to the problematic Back field, the problem would persist if I were to continue typing from the pasted contents.

In terms of your other questions:

  1. I haven’t been using the sticky/pinned fields. In fact, I wasn’t even aware this was a function. However I have found when the problem begins the affected box will have the formatting settings of the previously added card, and the “Remove formatting” tool will not apply to any text I add (e.g. if I start typing with pink text, and use the “Remove formatting” tool to revert the text to black, if I were to continue typing in that same box, any new added text will be pink)

  2. Unfortunately the problem persisted when using ANKI in safe mode. It did take longer for the problem to keep happening, but it did happen eventually. Interestingly while using ANKI in safe mode, the problem tended to occur with the Front field when adding cards, when previously the problem occured with the Back field. This switch-up in the problematic fields has continued even after I stopped using ANKI in safe mode

  3. My complete version information:

Anki 25.02 (038d85b1) (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.26100

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Button Colours Good Again [‘2494384865’, 2022-09-27T11:18, ‘None’, ‘’]
More Overview Stats 21 [‘738807903’, 2025-02-17T21:14, ‘None’, ‘’]
Progress bar - Visualize reviewed cards and remaining Fixed by Shige [‘1708250053’, 2024-11-10T20:00, ‘None’, mod]
Review Heatmap [‘1771074083’, 2022-06-30T02:43, ‘None’, ‘’]

===IDs of active AnkiWeb add-ons===
1708250053 1771074083 2494384865 738807903

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

Also the other issue that you suggested was the one I was referring to, although upon further investigation it appears that their issue is slightly different from mine. Unfortunately I’m apparently not allowed to add links to my posts though.

Thank you for your time :slight_smile:

Some backgroud about &nbsp;: This is the HTML code for a whitespace character that is to be shown. In normal HTML (without the use of something like <pre> or similar), only a single whitespace is shown at a time, regardless of how many whitespaces you put in the source, i.e if you had put wow, this is nice , this will render as wow, this is nice by default. Trailing whitespaces are also ignored. If you use this HTML code, you will force there to be a whitespace character, regardless of the characters before it.
Internally, when you are typing something in a field in Anki, if the last character is a whitespace, it gets converted to a nbsp code, assuming that the whitespace is intentional. Usually, if you continue typing, that gets converted into a regular whitespace character if there are non-whitespace (not completely sure about this) characters after it. What you described possibly is the default behaviour, because the program is not sure whether that whitespace character was added intentionally or not, so it doesn’t do anything about it.
If you copy from one field to the other, unless you paste it without formatting Ctrl + Shift + V, it copies the HTML from the original as well as the text. Could you try using the Erase tool on the top of the editor and see if that is what you wish to do? (Since you seem to have used a colour, I’d suggest you to select the text inside and then use the eraser tool, else the colour also will be erased)

When you copied from the Front field, did you copy from the HTML editor, or did you copy from what the display showed?

A non-breakable whitespace to be exact. E.g. Hello World will break into two separate lines, where the space is. Hello&nbsp;World on the other hand always tries to keep both words together (and thus adds no line break).


@Cia’s problem is actually pretty easy to reproduce.

Steps to reproduce

  1. Press the text color button / F7.
  2. Type Hello, followed by Space, followed by Enter.
  3. Repeat, as this is an intermittent issue and doesn’t always happen.

There is actually another intermittend issue in connection to that:
Following the steps from above, and then pressing Tab to switch to the next field sometimes adds two <br>, even though only one line break has been typed. This, too, is intermittent.

1 Like

[I’m repeating some of what others have posted, because I already wrote it yesterday, when I didn’t have time to finish editing my reply, but it doesn’t seem worth deleting.]

Those &nbsp;'s are definitely causing your mid-word-line-break issue. That is the HTML code for a “non-breaking space”. When every space in the sentence is one of those, the HTML treats the sentence as one continuous word. Since it’s got to break somewhere, and it can’t break at the spaces, it breaks wherever else it needs to keep the word in the space allowed.


So we’ve got the “what is happening” – but the “why it’s happening” might have to remain a bit of a mystery for now. Let’s jump over that to “what to do about it.”

How to fix existing notes – Try using Find and Replace to replace &nbsp; with a regular space. (Unless you think you have &nbsp;'s that you need to keep somewhere?)

How to stop it while it’s happening (without closing the Add window) – Cut the contents of the field, and then use Shift-Ctrl-V to paste it back into the field without formatting. I don’t know if that will cause the issue to go away for a while, or just fix that one field.

I would be interested to know what is happening in the HTML view when you’re doing that too, but it sounds similar to another issue where it’s hard to remove formatting from an empty field – Bold/italic/underline sticks at start of note.

“Did take longer” and “tended to occur” are hard to quantify – especially when we’re already talking about an intermittent issue. There might be too many variables and too much chance of observation/confirmation bias to get a good read on that. Unless it’s overwhelmingly longer, like 3 days instead of 10 minutes?

That the issue is switching between fields hints that it might be the toolkit to blame – as does the fact that closing/reopening the Add window fixes it – but this is probably good background information for anyone looking for a fix.

If you’ve been able to reproduce it, is that on version 25.02? Linux, not Windows, right?

Any patterns anyone can find in when it is happening will certainly help get it fixed! [That is, if it’s possible to fix from Anki’s end, and not a toolkit bug that we have to tolerate.]

I can reproduce both intermittent issues I mentioned above with

  1. Anki 25.02 (038d85b1) (ao)
    Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
    Platform: Linux-6.12.19-amd64-x86_64-with-glibc2.41
    (debian sid in a virtual machine)
  2. Anki 24.11 (87ccd24e) (ao)
    Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
    Platform: Linux-6.1.0-0.deb11.21-amd64-x86_64-with-glibc2.31
    (debian oldstable)
1 Like