Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
It is difficult to recall recent command-line from history, whose beginning matches the cuurrent command-line by "case-insensitive" way.
Describe the solution you'd like
Add a new option like histignorecase. When this is set, case is ignored when recalling command-line from history by <Up> and <Down>.
Describe alternatives you've considered
I can use the histget(), getcmdline(), and match() to achieve this feature. For example, something like this.
cnoremap <Up> <C-\>eUpIgnorecase()<CR> cnoremap <Down> <C-\>eDownIgnorecase()<CR> function UpIgnorecase() " Use above functions to return cmdline whose beginning matches current cmdline by case-insensitive way. endfunction function DownIgnorecase() " ... endfunction
But there is one problem. The <Up> and <Down> are used to go up and down the directory or menu when the wildmenu is used to complete filename or menu:
While the "wildmenu" is active the following keys have special
meanings:
<Left> <Right> - select previous/next match (like CTRL-P/CTRL-N)
<Down> - in filename/menu name completion: move into a
subdirectory or submenu.
<CR> - in menu completion, when the cursor is just after a
dot: move into a submenu.
<Up> - in filename/menu name completion: move up into
parent directory or parent menu.
I want to keep this feature, so I need to do something like this:
cnoremap <expr> <Up> {is completing filename or menu with wildmenu} ? '<Up>' : '<C-\>eUpIgnorecase()<CR>' cnoremap <expr> <Down> {is completing filename or menu with wildmenu} ? '<Down>' : '<C-\>eUpIgnorecase()<CR>'
However, AFAIK, there is no way to get whether {is completing filename or menu with wildmenu} or not.
To get this, I propose that wildmenumode() with |non-zero-arg| returns what the current completion is for. For example, when completing filename, wildmenumode(1) returns file. For this return value, the second argument of the getcompletion() would be suitable:
arglist file names in argument list
augroup autocmd groups
buffer buffer names
behave :behave suboptions
color color schemes
command Ex command (and arguments)
cmdline |cmdline-completion| result
compiler compilers
cscope |:cscope| suboptions
diff_buffer |:diffget| and |:diffput| completion
dir directory names
environment environment variable names
event autocommand events
expression Vim expression
file file and directory names
file_in_path file and directory names in |'path'|
filetype filetype names |'filetype'|
function function name
help help subjects
highlight highlight groups
history :history suboptions
locale locale names (as output of locale -a)
mapclear buffer argument
mapping mapping name
menu menus
messages |:messages| suboptions
option options
packadd optional package |pack-add| names
shellcmd Shell command
sign |:sign| suboptions
syntax syntax file names |'syntax'|
syntime |:syntime| suboptions
tag tags
tag_listfiles tags, file names
user user names
var user variables
This allows me to do what I want to do in the following way:
cnoremap <expr> <Up> wildmenumode(1) is 'file' || wildmenumode(1) is 'menu' ? '<Up>' : '<C-\>eUpIgnorecase()<CR>' cnoremap <expr> <Down> wildmenumode(1) is 'file' || wildmenumode(1) is 'menu' ? '<Down>' : '<C-\>eDownIgnorecase()<CR>'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
I believe you only intend to ignore case in the command argument. ":edit" and ":Edit" would still be different.
I actually would like this to be more clever. E.g. when typing ":e file" and pressing it would also find ":edit filemore". Also ignoring extra colons or white space, which cause no semantic difference.
I believe you only intend to ignore case in the command argument. ":edit" and ":Edit" would still be different.
I intend to ignore case in the whole keyword rather than only the command argument. For example, suppose that the output of :history :is as follows:
# cmd history
1 edit foo.txt
2 Edit bar.txt
3 edit baz.txt
4 Edit qux.txt
> 5 history :
I want to be able to type :edit b and press Up to complete :edit baz and press Up again to complete :Edit bar.txt.
I actually would like this to be more clever. E.g. when typing ":e file" and pressing it would also find ":edit filemore". Also ignoring extra colons or white space, which cause no semantic difference.
That sounds good! It would be interesting to add a new option like histsearchopt to change the behavior of Up / Down in the cmdline-mode so that we can specify something like set histsearchopt=ignorecase or set histsearchopt=clever.
I believe you only intend to ignore case in the command argument. ":edit" and ":Edit" would still be different.
I intend to ignore case in the whole keyword rather than only the command argument. For example, suppose that the output of
:history :is as follows:# cmd history 1 edit foo.txt 2 Edit bar.txt 3 edit baz.txt 4 Edit qux.txt > 5 history :I want to be able to type
:edit band press Up to complete:edit bazand press Up again to complete:Edit bar.txt.I actually would like this to be more clever. E.g. when typing ":e file" and pressing it would also find ":edit filemore". Also ignoring extra colons or white space, which cause no semantic difference.
That sounds good! It would be interesting to add a new option like
histsearchoptto change the behavior of Up / Down in the cmdline-mode so that we can specify something likeset histsearchopt=ignorecaseorset histsearchopt=clever.
Based on the description, it looks like you are looking for fuzzy search.
We should
add 'fuzzymatch' to 'wildoptions' and enable fuzzy completion for all the
commands.
I only intended to change the behavior of c_<Up> and c_<Down> for forward match search in the cmdline-history, but it is interesting to add a new item to wildoptions to change the behavior of c_wildchar and c_CTRL-D as well!
—
You are receiving this because you commented.
Based on the description, it looks like you are looking for fuzzy search.
We should
add 'fuzzymatch' to 'wildoptions' and enable fuzzy completion for all the
commands.I only intended to change the behavior of
c_<Up>andc_<Down>for forward match search in the cmdline-history, but it is interesting to add a new item towildoptionsto change the behavior ofc_wildcharand c_CTRL-Das well!
I have implemented the fuzzy match based completion for several
different completion types at:
Wow! Thank you very much. I'll try it later.
—
You are receiving this because you commented.
@yegappan i tried.. looks nice, though.....
anyway, looking forward it..
—
You are receiving this because you commented.
@yegappan i tried.. looks nice, though.....
- compared to ignorecase, this 'fuzzy' probably listed massive items, not sure if everyone like it..
- cannot set/work with cur 'tagfile' option, looks was exclusive each other.. was it intended?
- it is 'matchfuzzy', not 'fuzzymatch', expression in ticket is diff like in code, may confused someone..
- yea, so far looks canNot compl for file names (if there uppercase letters in fs name)..
anyway, looking forward it..
Are you referring to the tag completion?
Yes, and means combined wildoption as fuzzy plus tagfile.
// looks somewhere had such similar feature, I like it, wish this would be applied ASAP. :-)
—
You are receiving this because you commented.
Hi, I also tried... It's working fine! I hope this feature is introduced.
@brammool Any thoughts about this?
—
You are receiving this because you commented.
We should consider some tweaking before including this.
—
You are receiving this because you commented.
sure, understood.. just felt it would help user speed up typing cmd much, i think.. :-)
// but it's ok to wait, or withdraw if it had outage..
—
You are receiving this because you commented.
—
You are receiving this because you commented.
@yegappan is it good time to merge this fuzzy complete now? :-)
// fuzzy complete for filename probably not much useful, but cmd (or tag as well) looks more useful.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
![]()