markonm / traces.vim

Range, pattern and substitute preview for Vim
MIT License
735 stars 13 forks source link

Range highlight is off after recent commit #27

Closed novikserg closed 5 years ago

novikserg commented 5 years ago

Hey Marko,

Thanks for an awesome plugin!

One thing I noticed after recent update is that ranges are no longer being previewed for commands such as :1,10d or :32,55y. Although commit https://github.com/markonm/traces.vim/commit/46e01b6159a21c89695b9d03ea3529ddc92d3b1f aims to prevent ambiguous matches, I don't quite understand why these are considered ambiguous in this case, so decided to file a bug report.

Best regards, Sergey

markonm commented 5 years ago

Hi, I'm glad you like the plugin!

Range highlighting is disabled only for ranges that do not include any pattern or mark specifier. So if range is comprised only of ., $ or N specifiers its preview will be turned off. However, you can force range preview for those ranges by appending and deleting / at the end of a range or before range is written.

:1,10d is not ambiguous but :0d is ambiguous; the user might not want to delete first line but is rather in the process of typing :0debugg[reedy]. In the latter case, highlighting and positioning should be considered unwanted and distracting. :[range]y is not ambiguous as there doesn't exists another command which starts with letter y.

Some other examples:

:[N]t     Synonym for copy.    or  :[count]tf[irst], :[N]tabm[ove]
:[N]v     :[range]v[global]    or  :[N]vs[plit], :[N]vne[w]
:[N]s     :[range]s[ubstitute] or  :[N]sl[eep], :[N]sv[iew], :[N]sf[ind], etc.
:[N]a     :{range}a[ppend]     or  :[N]al[l], :[range]argd[elete]
:[N]c     :{range}c[hange]     or  :[N]checkt[ime]
:[N]g     :[range]g[lobal]     or  :[range]go[to]
:[range]w :[range]w[rite]      or  :[range]windo

In all those cases it is not known whether user finished typing the command or not.

I'll add a way to enable range preview for ranges that are comprised only of numerical specifiers for those who do not mind occasional unwanted range preview.

novikserg commented 5 years ago

Wow that's really amazing, thanks heaps!