Code Monkey home page Code Monkey logo

Comments (2)

inkarkat avatar inkarkat commented on July 17, 2024

The plugin assumes direct use, so a user wouldn't add a pattern again that's already highlighted, and so it instead interprets such as the desire to un-highlight it. This toggling behavior is quite deeply embedded in the plugin's implementation, as you've already found out :-)

I understand that in your integration use case, the toggling is not desirable; as in your mapping, the highlighting is more a side effect, whereas the Fugitive grep is the main action.

I think a separate plugin function that allows you to query whether a pattern / literal text is already highlighted offers even more flexibility than adding alternative functions that do not toggle. In your proposed implementation, you would have to replace the :Mark invocation with calling the new mark#DoMarkAndSetCurrentDontClear() function, whereas with a separate query function, you would call that first and only on a negative result invoke :Mark (a positive result means that the mark already exists).


I've added mark#GetMarkNumber() to the code.

With it, your mapping would look like this:

nnoremap gr :let @/=""<CR>:if !mark#GetMarkNumber(expand('<cword>'), 1, 0)<Bar>execute 'Mark' expand('<cword>')<Bar>endif<CR>:silent exec ":Ggrep! -w <C-R><C-W>"<CR>:copen<CR>:redr!<CR>

I hope that addresses your problem; let me know that you think!

from vim-mark.

Snorch avatar Snorch commented on July 17, 2024

Hi @inkarkat Your patch with new plugin function mark#GetMarkNumber() is a perfect solution for my case! Thanks a lot for such a quick and helpful reply!

Also big thanks for such a useful plugin!

Closing as done.

from vim-mark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.