Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental, add total match count #19

Merged
merged 34 commits into from
Dec 10, 2017
Merged

experimental, add total match count #19

merged 34 commits into from
Dec 10, 2017

Conversation

bounceme
Copy link
Collaborator

if @romainl is into it. this will probably need to be optional

@romainl
Copy link
Owner

romainl commented Oct 25, 2017

Thanks, I'll wait until this week-end to try it locally.

@auwsmit
Copy link

auwsmit commented Oct 31, 2017

Great patch. If romainl doesn't like it, it'd be great as its own separate plugin.

And a suggestion: putting the search term after the numbers. Like:

/match 123 of 456 for searchterm

As it is now going before, the match results will have an inconsistent position depending on the length of your query.

Alternatively, just don't show the search term at all, since it's already shown by its matching results. Like:

match 123 of 456

It's the smallest of gripes though and I can understand wanting to keep the search term in its same place for pure consistency.

@auwsmit
Copy link

auwsmit commented Oct 31, 2017

Just found a bug: Exits visual mode when cursor goes over a search result with hlsearch on. Probably from the norm!

@bounceme
Copy link
Collaborator Author

i'll look for the cause of that bug, thanks. my main focus is on making this as close to the default behaviour as possible, also if the timeout is reached it doesn't break your concentration by looking really different

@auwsmit
Copy link

auwsmit commented Nov 25, 2017

Found another bug on my end: any time a search mapping (e.g. *, n, etc.) has zz at the end, it strangely causes the results message to disappear most of the time.

To reproduce: map n nzz and compare n to N. The message should usually disappear for n when zz moves the screen, but never for N

edit: could just be gvim on Windows, I haven't tested in Unix gvim or a terminal because Windows blows

@bounceme
Copy link
Collaborator Author

							*z.*
z.			Redraw, line [count] at center of window (default
			cursor line).  Put cursor at first non-blank in the
			line.

							*zz*
zz			Like "z.", but leave the cursor in the same column.
			Careful: If caps-lock is on, this command becomes
			"ZZ": write buffer and exit!

redraw.

@auwsmit
Copy link

auwsmit commented Nov 25, 2017

Ah, I didn't catch that, thanks. Also, random suggestion that might be dumb or pointless:

Could this

exe "silent! norm! :let g:cool_char=nr2char(screenchar(screenrow(),1))\<cr>"
if g:cool_char =~ '[/?]'
  ...
endif

be replaced with just

let g:cool_char = v:searchforward ? '/' : '?'
...

?

@bounceme
Copy link
Collaborator Author

bounceme commented Nov 25, 2017

no, v:searchforward reflects whether you typed the pattern after pressing ? or /

"this seems to work
augroup PCOOL
  au!
augroup END
nnoremap <silent>n :<C-U>set scrolloff=999\|au PCOOL cursormoved * set scrolloff&vim\|
      \ au! PCOOL cursormoved *<cr>:call feedkeys(max([v:prevcount,1]).'n','n')<cr>

@auwsmit
Copy link

auwsmit commented Nov 25, 2017

Sorry if I'm misunderstanding, but v:searchforward in fact reflects the last direction of the search. Based on my testing, it's functionally equivalent to check that variable rather than the lowerleft-most character of the window (as I showed above), and seems like a more optimal approach.

Also good idea with scrolloff to center without redrawing

@bounceme
Copy link
Collaborator Author

doesn't reflect the movement direction, like vim by default does

@auwsmit
Copy link

auwsmit commented Nov 25, 2017

What's an example of g:cool_char = v:searchforward ? '/' : '?' giving the wrong character?

@bounceme
Copy link
Collaborator Author

we don't know which direction the last movement was in.

?let<cr>N echoes /let by default

@auwsmit
Copy link

auwsmit commented Nov 25, 2017

Oh... I was using my vimrc where I have the results bit put into a function that's attached to the end of all my search mappings, so v:forwardsearch was always up-to-date and worked flawlessly for me. But you're right that using the fancy vim-cool method, it's totally wrong. Sorry for wasting your time, I was up very late last night.

@bounceme
Copy link
Collaborator Author

bounceme commented Dec 8, 2017

guess #23 also should apply to the counting

@romainl
Copy link
Owner

romainl commented Dec 9, 2017

@bounceme, this looks good and useful but I'd prefer to have it behind an option as it is not directly related to the original purpose of vim-cool.

@bounceme
Copy link
Collaborator Author

merging it. thanks for the Readme updates @romainl

@bounceme bounceme merged commit a60802f into master Dec 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants