Seppe
Seppe

Reputation: 3

How do I change the way vim autocompletes commands?

I use the :split in vim all the time, I however neveer uses :spelldump or :spell* in general.

Is there any way to make :split be the first commmand to appear when autocompleting on :sp ?

Upvotes: 0

Views: 65

Answers (1)

glts
glts

Reputation: 22684

Like I said in the comment you don't need to autocomplete for this particular use case, :sp will do the trick. If you enter part of a builtin command that is ambiguous, Vim prefers one command over the other:

  • :s could be :substitute, :split, :spelldump, etc., but for Vim it is :s[ubstitute]
  • :sp could be :split, :spelldump, :sprevious, etc., but for Vim it is :sp[lit]

In the help this is indicated with square brackets around the optional part of the command just as is shown above.

To answer the general question: I don't think you can change the way Vim autocompletes commands. You can define your own shorter command (which must be uppercase), e.g. :command! S split. Or you could define a mapping, e.g. :nnoremap \s :split<CR>. Finally, you could use a builtin normal mode command, which for this particular use case is simply CtrlW followed by S.

Upvotes: 2

Related Questions