When typing a number in spacemacs all kind of numbers are being suggested. I can autocomplete them with enter. I like this behaviour in the case I'm typing words (made up of letters). But I don't want this behaviour when I'm typing numbers.

Often I have to type a number at the end of a line. So for instance, when I want the number 10 but type enter in order to go to the next line, the 10 I type expands to 1001004005438142.

example of a number being suggested when typing 10

To avoid the 10 being expanded, I can type a space and after that an enter. That's the way I handle this at this moment.

However I just don't want numbers to automatically expand.

What functions or strings can I put into my .spacemacs (or init.el) to prevent numbers, and only numbers, from being suggested (and consequently being expanding when I type enter)?


4 Answers 4


It seems to be as simple as:

(setq company-dabbrev-char-regexp "[A-z:-]")

I got this far by studying this q&a: How can I prevent company-mode completing non-English chars?

  • I still worry a bit about the regex I used here, since I don't know if it matches every word/expression that I want to be suggested...
    – jajpater
    Sep 5, 2018 at 7:57
(push (apply-partially #'cl-remove-if
                       (lambda (c) (string-match-p "\\`[0-9]+\\'" c)))

The above code snippet is copied from the discussion at How to let company-dabbrev ignore numbers analysis

  • Yes, this is the best answer, though I would delete the ending \\; anchor so that anything that starts with a number is exempt from completion. Apr 12, 2022 at 11:48

When this drop-down menu for numbers completion appears, typically the mode-line would show the company backend which is causing this completion. You can remove this backend from the list 'company-backends.

E.g. if company-dabbrev is doing it,

(delete 'company-dabbrev company-backends)

Alternatively, you could prevent company from completing without your consent by setting company-idle-delay to a large number. Mine is

(setq company-idle-delay 999999)
  • Thanks for your answer but I don't want to lose company-dabbrev in its entirety, since (as far as I understand) it is responsible for autocompletion of the words previously used in the buffer.
    – jajpater
    Sep 5, 2018 at 7:33
  • OK, are you sure that dabbrev backend is causing the numbers drop down appearance ?
    – Jeeves
    Sep 6, 2018 at 9:54
  • Yes, it is, since, changing the company-dabbrev-char-regexp changes the drop down behaviour.
    – jajpater
    Sep 6, 2018 at 14:40

I suffered the same irritation. The best answer is to stop it at the dabbrev level, not company-mode. This works with cofu and other completion libraries as well:

(setq dabbrev-abbrev-skip-leading-regexp "[0-9]\\|\\$\\|\\*\\|/\\|=")

The only relevant bit is the first alternative with [0-9], causing dabbrev to forego completion when there is a digit at the beginning of the word to be completed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.