Kakoune: Case Insensitive Command Completion

Created on 5 Nov 2020  Â·  4Comments  Â·  Source: mawww/kakoune

Feature

As far as I can see, all kakoune commands from the : prompt are lowercase. It'd be nice if uppercase text still matched. I understand that this interferes with user-defined commands that are uppercase, so I also understand if this is regarded as a bad idea, but at the very least I think the default config would benefit from also aliasing W, E, and Q, as users will already be pressing shift to enter :. I think that it is a mistake the occurs, at least for me, frequently enough that I have a pronounced opinion. I can't imagine a significant case where just aliasing W, E, and Q would be problematic. As for longer commands, I think that the kakoune autocomplete should allow for case-insenitive matching, and if there are any commands that are uppercase, they should simply rate higher.

I have a few upper case aliases in my kakrc, and they're certainly helpful, but it'd also be nice to have case insensitive completion universally.

Usecase

I can't tell you how many times I've enter:W to save a buffer, gotten an error message, and not noticed and moved on, and then be confused when I'm still running into something I thought I just fixed.

Additionally, for longer commands, I'll often write the first 4 letters of a command before noticing my capitalization mistake, usually leading me to deleting the whole command and starting over.

feature request

Most helpful comment

I'm not proposing that :Command evaluates :command, I'm suggesting interactive command autocomplete displays case-insensitive completions. The user would have to hit tab, to use the completion. This wouldn't effect any evaluation, I still expect :Command to only call :Command.

What I was imagining:
Assume Command and command are both defined.
A user entering :Comm is displayed with two autocomplete options: Command and command

  • Hitting <tab> <ret> at this point executes Command
  • Hitting <tab> <tab> <ret> at this point executes command.

I know we shouldn't make command names case insensitive, I just think that command autocomplete should consider case insensitive options when displaying autocompletes. I was unclear in my previous description of my idea, and I'm sorry.

All 4 comments

My take on this issue is that on a Qwerty keyboard it's not very efficient to always have to press shift-; to trigger : which is used very often to type commands. In comparison, I use the ; primitive (reduce selections to their cursor) rarely.

Therefore, this exchange makes perfect sense for my usage:

map global normal ; ':'                                
map global normal : ';'

It solves your issue as no more shift keys is involved to enter prompt mode.

I really like @Delapouite's idea, my only problem being that this is extra config for behavior I think would be beneficial to be default. I don't think the ; : swap is a good idea to make universal, as it (1) interferers with everyone's muscle memory, and (2) pulls us a little farther from vim (which I don't personally hate, but is a stated goal).

I'm writing a PR right now that adds an option to enable case-insensitive matching, which again would be extra work, but could be enabled by default if decided to be a good idea.

Even with the option to enable case-insensitive matching, I still believe that kakoune should allow W, E and Q by default. I don't think it's meaningfully harmful, and it's surprisingly convenient.

In the world of Vim plugins, non-builtin commands are often capitalised to indicate that they are provided by a plugin. One example that came to mind is Fugitive.

Why would the editor assume that, for example, :Git is the same as :git? Even worse, :GIT and :Git and :git?

The issue is that you are not typing accurately enough, and you have the perfect workaround through aliases. I myself have a couple of such workarounds in my configuration:

# Avoid fat finger issues
unalias global wq write-quit
map -docstring 'work around for clumsy object selection' global object <a-p> p

Going further, having an option-controlled side effect on command execution is a problem in scripting. Plugins writers wouldn't be able to know the outcome of calling :Command in their own scripts.

Computing completion candidates would also get messy, as this hypothetical option would impact whether capitalised commands are proposed as candidates — a lot of extra logic for a problem you've already fixed.

I'm not proposing that :Command evaluates :command, I'm suggesting interactive command autocomplete displays case-insensitive completions. The user would have to hit tab, to use the completion. This wouldn't effect any evaluation, I still expect :Command to only call :Command.

What I was imagining:
Assume Command and command are both defined.
A user entering :Comm is displayed with two autocomplete options: Command and command

  • Hitting <tab> <ret> at this point executes Command
  • Hitting <tab> <tab> <ret> at this point executes command.

I know we shouldn't make command names case insensitive, I just think that command autocomplete should consider case insensitive options when displaying autocompletes. I was unclear in my previous description of my idea, and I'm sorry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

notramo picture notramo  Â·  3Comments

abitofalchemy picture abitofalchemy  Â·  3Comments

alexherbo2 picture alexherbo2  Â·  3Comments

MasterOfTheTiger picture MasterOfTheTiger  Â·  4Comments

valerdi picture valerdi  Â·  4Comments