Code Monkey home page Code Monkey logo

Comments (3)

lfilho avatar lfilho commented on July 24, 2024

Oooh halloween bug. Spooky!

Good catch, @felippenardi! Thanks! I will try to tackle it soon. Nevertheless, feel free to open a PR if you wish. :)

from cosco.vim.

lfilho avatar lfilho commented on July 24, 2024

So... I've been playing and researching a bit about this... I think this is actually in sync with the way vim works: if you execute a :s command (which is what cosco does under the hood) and then undo that :s, vim will automatically place the cursor in the beginning of the line.

It kind of makes sense when you think that you're executing an action in the whole line and then reverting the whole line modification.

To my basic VimL understanding, the only way to "cheat" this would be manipulate the undo tree, which I don't even think it's possible or make invisible steps, for example: going to insert mode, insert a char, delete it right after, and then executing the Cosco action (hence undo would go to the previous insertion point (which was were your cursor was).

But I'm not very keen on this solution as it may have undesired side effects as changing the user's jump list or maybe even make the command slower/noticeable in slower environments. And this a bad practice for plugins (to change vim's default behaviour). What do you think?

What I would suggest until we find a solution for this case is: after undoing (and vim placing your cursor in the beginning of the line), hit Ctrl-o to jump back to where you were.

I'd be happy to hear from more experienced vim scripters :)

from cosco.vim.

felippenardi avatar felippenardi commented on July 24, 2024

That makes sense! :)

from cosco.vim.

Related Issues (18)

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.