Visual feedback after executing mapping












1















I have the following mapping in my ~/.vimrc file:



 map <F3> my0v$"+y`y


It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?










share|improve this question


















  • 1





    No answer, but isn't that the same as map <F3> "+yy?

    – Ralf
    5 hours ago











  • This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

    – Peter Rincker
    4 hours ago
















1















I have the following mapping in my ~/.vimrc file:



 map <F3> my0v$"+y`y


It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?










share|improve this question


















  • 1





    No answer, but isn't that the same as map <F3> "+yy?

    – Ralf
    5 hours ago











  • This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

    – Peter Rincker
    4 hours ago














1












1








1








I have the following mapping in my ~/.vimrc file:



 map <F3> my0v$"+y`y


It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?










share|improve this question














I have the following mapping in my ~/.vimrc file:



 map <F3> my0v$"+y`y


It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?







key-bindings






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









SabreWolfySabreWolfy

344313




344313








  • 1





    No answer, but isn't that the same as map <F3> "+yy?

    – Ralf
    5 hours ago











  • This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

    – Peter Rincker
    4 hours ago














  • 1





    No answer, but isn't that the same as map <F3> "+yy?

    – Ralf
    5 hours ago











  • This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

    – Peter Rincker
    4 hours ago








1




1





No answer, but isn't that the same as map <F3> "+yy?

– Ralf
5 hours ago





No answer, but isn't that the same as map <F3> "+yy?

– Ralf
5 hours ago













This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

– Peter Rincker
4 hours ago





This will copy the line character-wise instead of linewise. However, it will also copy the newline so it feels more linewise. I agree that it would probably be easier to just do yy/Y or :yank and just accept to do a little cleanup on paste/put.

– Peter Rincker
4 hours ago










1 Answer
1






active

oldest

votes


















4














You have options:




  • Explicitly put an :echo at the end of your mapping. map <key> foo:echo "done"<cr>

  • Use 'showcmd' which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)

  • Use a plugin like vim-highlightedyank to quickly highlight the last yank


General rule of thumbs for mappings:




  • Supply a mode for mappings. e.g. nmap for normal mode

  • Use *noremap variants unless you want remapping to occur or using a <Plug> mapping


This means you mapping would look like:



nnoremap <F3> my0v$"+y`y


Some more thoughts:




  • This is very similar to "+yy/"+Y, :yank +, or V"+y. There is another newline in the register, but it is easy to reason about.

  • You may not want the ending newline at all, so use g_ instead of $.

  • This mutates the y mark. This could be surprising, consider using a :yank or yy/Y

  • Could "cast" put/paste or change the register type to accomplish the same effect. e.g. nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>


Personally, I lean toward using vim-highlightyank and the following mapping:



nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>





share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "599"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18565%2fvisual-feedback-after-executing-mapping%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You have options:




    • Explicitly put an :echo at the end of your mapping. map <key> foo:echo "done"<cr>

    • Use 'showcmd' which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)

    • Use a plugin like vim-highlightedyank to quickly highlight the last yank


    General rule of thumbs for mappings:




    • Supply a mode for mappings. e.g. nmap for normal mode

    • Use *noremap variants unless you want remapping to occur or using a <Plug> mapping


    This means you mapping would look like:



    nnoremap <F3> my0v$"+y`y


    Some more thoughts:




    • This is very similar to "+yy/"+Y, :yank +, or V"+y. There is another newline in the register, but it is easy to reason about.

    • You may not want the ending newline at all, so use g_ instead of $.

    • This mutates the y mark. This could be surprising, consider using a :yank or yy/Y

    • Could "cast" put/paste or change the register type to accomplish the same effect. e.g. nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>


    Personally, I lean toward using vim-highlightyank and the following mapping:



    nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>





    share|improve this answer






























      4














      You have options:




      • Explicitly put an :echo at the end of your mapping. map <key> foo:echo "done"<cr>

      • Use 'showcmd' which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)

      • Use a plugin like vim-highlightedyank to quickly highlight the last yank


      General rule of thumbs for mappings:




      • Supply a mode for mappings. e.g. nmap for normal mode

      • Use *noremap variants unless you want remapping to occur or using a <Plug> mapping


      This means you mapping would look like:



      nnoremap <F3> my0v$"+y`y


      Some more thoughts:




      • This is very similar to "+yy/"+Y, :yank +, or V"+y. There is another newline in the register, but it is easy to reason about.

      • You may not want the ending newline at all, so use g_ instead of $.

      • This mutates the y mark. This could be surprising, consider using a :yank or yy/Y

      • Could "cast" put/paste or change the register type to accomplish the same effect. e.g. nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>


      Personally, I lean toward using vim-highlightyank and the following mapping:



      nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>





      share|improve this answer




























        4












        4








        4







        You have options:




        • Explicitly put an :echo at the end of your mapping. map <key> foo:echo "done"<cr>

        • Use 'showcmd' which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)

        • Use a plugin like vim-highlightedyank to quickly highlight the last yank


        General rule of thumbs for mappings:




        • Supply a mode for mappings. e.g. nmap for normal mode

        • Use *noremap variants unless you want remapping to occur or using a <Plug> mapping


        This means you mapping would look like:



        nnoremap <F3> my0v$"+y`y


        Some more thoughts:




        • This is very similar to "+yy/"+Y, :yank +, or V"+y. There is another newline in the register, but it is easy to reason about.

        • You may not want the ending newline at all, so use g_ instead of $.

        • This mutates the y mark. This could be surprising, consider using a :yank or yy/Y

        • Could "cast" put/paste or change the register type to accomplish the same effect. e.g. nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>


        Personally, I lean toward using vim-highlightyank and the following mapping:



        nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>





        share|improve this answer















        You have options:




        • Explicitly put an :echo at the end of your mapping. map <key> foo:echo "done"<cr>

        • Use 'showcmd' which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)

        • Use a plugin like vim-highlightedyank to quickly highlight the last yank


        General rule of thumbs for mappings:




        • Supply a mode for mappings. e.g. nmap for normal mode

        • Use *noremap variants unless you want remapping to occur or using a <Plug> mapping


        This means you mapping would look like:



        nnoremap <F3> my0v$"+y`y


        Some more thoughts:




        • This is very similar to "+yy/"+Y, :yank +, or V"+y. There is another newline in the register, but it is easy to reason about.

        • You may not want the ending newline at all, so use g_ instead of $.

        • This mutates the y mark. This could be surprising, consider using a :yank or yy/Y

        • Could "cast" put/paste or change the register type to accomplish the same effect. e.g. nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>


        Personally, I lean toward using vim-highlightyank and the following mapping:



        nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 3 hours ago









        Peter RinckerPeter Rincker

        10.1k11728




        10.1k11728






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Vi and Vim Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18565%2fvisual-feedback-after-executing-mapping%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'