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

Remember search value #464

Closed
plbowers opened this issue Oct 30, 2016 · 16 comments
Closed

Remember search value #464

plbowers opened this issue Oct 30, 2016 · 16 comments

Comments

@plbowers
Copy link

plbowers commented Oct 30, 2016

When I search for text

/abc

and then after a few other movements decide to search again, I know that I can press n or N but often I have pressed / or ? in a natural, reflex action before I remember that it is the same search as before. In vim that's not a problem because if I don't specify any search value (just pressing RETURN) then it defaults to searching for the last text I searched for. In VMP searching for (nothing) (pressing RETURN after / or ?) seems to cancel the search.

It would be nice if VMP duplicated vim's behavior as it is a more useful default. (Canceling the search already can be done by means of so there's no need for an additional way to do it. However, duplicating the most recent search would require moving my fingers over to the arrow keys - a very un-vim way to do things)

@plbowers
Copy link
Author

plbowers commented Oct 30, 2016

This definition of handleConfirmSearch() in motion-search.coffee will fix this problem:

handleConfirmSearch: ({@input, @landingPoint}) =>
  searchChar = if @isBackwards() then '?' else '/'
  if @input in ['', searchChar]
    @input = @vimState.searchHistory.get('prev')
    atom.beep() unless @input
    if @isIncrementalSearch()
      @incrementalSearch = false
  @processOperation()

(The problem was because I had incremental search turned on and this capability was explicitly disabled for incrementalSearch. I've changed it so I just turn off incrementalSearch if I'm in this situation where I've already specified the search text.)

@plbowers
Copy link
Author

I left this PR in my next PR as well. You may want to NOT merge this one and JUST merge that one, thereby pulling them both in without any merge conflicts...

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

AFAIR why I disabled this feature for incremental-search is I want to search / or ? when I type /.
How do you save this situation, I myself don't want this feature, I mean existing current feature is good.

@plbowers
Copy link
Author

Hitting the initial / or ? initiates the search, but doesn't search. What you search for comes after that.

If you use 2 slashes or 2 questions marks (followed by enter) then, according to the vim standard, it's the same as just hitting a single slash or question mark and searches for the previously-searched string. A nice convenience for people who are used to vim.

If someone wants to search for a slash or a question-mark then the preferred (vim) way to do it is to press / or ? to get into search mode and then type back-slash followed by that special character. The mnemonic / itself comes from the regex delimiters and, obviously, if you're searching for a slash in a regex then you obviously need to escape it with the backslash. So it's all a very sensible and thought-through arrangement.

Now as I play around a little more deeply I see that regex is only partially implemented, so that does move it a step away from vim already. (For instance, ^ and $ anchors work but [...] character classes do not.)

I'm sure none of this is in any way new to you. I'm just thinking it through "out loud."

My personal preference (obviously counting very little as I am extremely new to this project) is "when in doubt follow vim" - in other words, unless there is a significant advantage realized by deviating from vim then it makes sense (note name of project) to follow vim. In this case the disadvantage of needing to type a backslash before the slash or question-mark seems negligible to me. My preference - yours is probably different.

So if you want to be able to search for / with // and ? with ?? then one alternative would be to make it so that /<return> and ?<return> acted like vim but //<return> and ??<return> deviated as you prefer.

Or, alternatively, it could become a configurable item for "vim-compatible with incremental search" or something like that.

@plbowers
Copy link
Author

plbowers commented Oct 30, 2016

Not sure if I should ask here or elsewhere, but this discussion has sparked some curiosity - feel free to move the discussion elsewhere or ask me to do the same.

What is the basic underlying philosophy on this package? I assumed, based on the name, that it was to implement vim capabilities within atom and expand beyond that when appropriate/possible to take advantage of the capabilities available in atom. If that's not the case, could you give an idea of what the philosophy is or perhaps point me to something that you've already written to explain it?

In other words, what determines when a given feature follows vim and when it deviates from vim?

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

I like pure Vim, but that not means I appreciate every feature/behavior of pure Vim.
For double ?? and // feature, I don't like it, I want search ? when I type ?.
Even if you say It's vim-way, I'm not so much interesting in vim-way in this part.

For 2nd question, I'll put comment after that.

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

The closed issue labeled discussion include some of info.
The closed issue labeled atom-is-not-vim might include my judgments.

Also these comment include some info.
#52 (comment)
#441 (comment)

I like Vim, I respect Vim but what I'm doing in this package is re-thinking each feature very non-strict way.
So vim-mode-plus already include lots of experimental feature.
But vim-mode-plus have function-text-object included but not yet support sentence-text-object.
What is the priority? What is the philosophy?
None.
Just I'm OK without sentence-text-object, but cannot live without function-text-object.

I'm working for vim-mode-plus just ordered by my motivation.
vim-mode-plus is maintained only by me(and I like this dev style in most case at least now), how much I shout loud ideal project's philosophy, it's so easily breaks if maintainer lost motivation.

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

Btw if you make feature enhancement suggestion, please write concise and short explanation.

Did you read https://github.com/t9md/atom-vim-mode-plus/wiki/IssueReport#ideal-issue-reporting.

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

The feature you want is just

"When incremental-search was enabled, ? ? or / / keystroke want to repeat last search but not"

Then I can suggest such like
"I don' want this that feature as default, but adding option is not difficult, is that really necessary? OK I'll experimentally add reapatLastSearchByDoublingSearchKeystroke like config options"

I don't want directly dive into the-vim-way discussion.

@plbowers
Copy link
Author

I will try to be concise - it's a weakness of mine.

What if I implement it so that ?? finds ? and // finds / but / repeats last search forward and ? repeats last search backward when in incrementalSearch mode?

@t9md
Copy link
Owner

t9md commented Oct 30, 2016

Want make sure. You mean / enter and ? enter repeat last search in respective direction?

@t9md
Copy link
Owner

t9md commented Oct 31, 2016

OK I think I understand your original request. Repeat last search with / enter or ? enter.

I didn't read all of your explanation because it's seems to be too long( I still not yet read all).

@plbowers
Copy link
Author

Yes, / enter and ? enter repeat last search in respective direction. That is the alternative I am proposing.

If you agree I will need to make a few mods to my PR.

@t9md
Copy link
Owner

t9md commented Oct 31, 2016

The changes required to support this is really simple, I want to modify it by myself.

What's the non-alternative original request?

@plbowers
Copy link
Author

The non-alternative original request was what you do NOT want - // and ?? would also (in addition to /enter and ?enter) repeat last search in respective direction. I'm fine setting the original aside and going with just /enter and ?enter.

@t9md
Copy link
Owner

t9md commented Nov 3, 2016

Done in #474.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants