When doing spell checking, keying z=, brings up a selection list, as shown bellow.

select correct

As you can see the correct spelling; "i.e." is not shown as any of the options. I would like to enhance this menu, so that I can instead just type in "i.e." and press enter and have it replaced.

It would also be nice, if as part of the same step if I could start typing the name of one of the presented options and tab compete to that -- my mind works better on replacing words by entering words rather than by entering numbers.

I suspect this needs to be done with a plug-in but I'm not certain that it is not just a config option.

Looking at the spell_suggest() function in spell.c this doesn't seem possible with z=. After getting & displaying all the possible suggestions, it does:

/* Ask for choice. */
selected = prompt_for_number(&mouse_used);

prompt_for_number() lives in misc1.c, and does exactly what you would expect it to do: it prompts for a number (also see get_number() in the same file). Mappings or other input isn't allowed.


A second option is to use Vim's spell "completion" through Ctrl x + s or Ctrl x + Ctrl s1 in insert mode. This does roughly what you want. You can choose from the completions with Ctrl n and Ctrl p or the arrow keys, or type your own improvement.

You can use the supertab plugin to do this with your Tab key. :help ins-completion also has a CleverTab() function which you could adapt for this.

For more information, see: :help ins-completion, :help i_CTRL-X_s


Finally, Vim has the spellsuggest() function, which returns a list of spelling suggestions:

:echo spellsuggest('hellz')
['hells', 'hello', 'hell', 'help', 'halls', 'heals', 'heels', 'hills', 'hulls', 'hell''s',
 'hellos', 'hell’s', 'held', 'helm', 'tell', 'well', 'bells', 'cells', 'dells', 'fells',
 'helot', 'helve', 'hertz', 'hilly', 'holly']

You could use this function to construct your own spell suggestion screen.


Footnote

1: Note that using Ctrl s may not work, as the docs mention:

NOTE: CTRL-S suspends display in many Unix terminals. Use 's' instead. Type CTRL-Q to resume displaying.

If you're using gVim, using Ctrl s should work. Or you could disable this in your terminal with stty -ixon.

I'm going to expand/consolidate @quincy-bowers answer:

  1. You can not enter you own suggestions from the spell suggestions screen.
  2. It doesn't make much sense (in VIM) to enter your own suggestions form the spell suggestions screen.

VIM is a text editor. Since that is what it does best it leaves the editing to itself. In other words the answer to change a misspelled word to your own custom suggestion just press enter to dismiss the suggestion list and then change the word to your correct spelling manually. (ciw works perfect for that).

Then (as @quincy-bowers suggested) if you want the custom correct spelling to show up in subsequent suggestion lists type zg when the cursor is on the word and it will be added to your spelling dictionary (see :help zg for details).

However, after saying all that, it hasn't stopped the clever folks who use VIM from finding alternatives (unlimited ways to skin a cat they say) and so you could try an alternative plugin for example unite-spell-suggest.

  • Describing the current workflow is more a comment than an answer. Though you do explain it well. – Lyndon White Feb 19 '15 at 3:55
  • 1
    @Oxinabox perhaps you looking for something more on the lines of: vim.org/scripts/script.php?script_id=4929 maybe? – Sukima Feb 19 '15 at 4:12
  • Yes, that is much more like what I am looking for. – Lyndon White Feb 19 '15 at 4:14

Without adding any plugins you can add a known good word to your spell file. Rather than z= to bring up the spelling suggestions, visually select the text you want to add to the spell file and press zg.

I should also note that from within the spell suggestion window you can use the mouse to select the one you want as long as you have enabled the mouse for NORMAL mode. I have set mouse=a set in my .vimrc, for instance, which enables the mouse in all modes whether I am in Vim or gVim.

I don't think the other things you want can be accomplished without a plugin or changing Vim itself.

  • 1
    These are all useful tips, but I don't see how they answer the question? – Martin Tournoij Feb 16 '15 at 15:35
  • @Carpetsmoker I could say the same about your own answer. I told him it wasn't possible and offered a change of workflow as a possible work around. Just like you did. – Quincy Bowers Feb 16 '15 at 17:16
  • 1
    @MartinTournoij This answer actually gives a solution to the problem: Needs to include new word > zg executes such inclusion. – nilon Aug 8 at 22:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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