This vim tip of the week was submitted by Andrew.  Many thanks.  Do you have a vi/vim tip that you’d like to share with the world?  Visit my contact page and send me your idea!

This vim tip relates to updating multiple windows or tabs within vim with a single command.  If you ever edit multiple files at once, or use the tabbing or windowing feature of vim this can save you some typing.  To do this we’d use the command:

:windo {cmd}

As Andrew outlines in his submission:

This is a fantastic command that has saved me much typing since I discovered it. Put simply, it executes {cmd} once for each open Vim window. If you've just opened a large number of files each in their own window and need to do the same thing in each, this is what you want.

Here is an example of using :window {cmd} to do a find and replace across multiple files:

 :windo %s/search/replace/g

There are also the :windo related commands such as:

:bufdo {cmd} - run {cmd} in each buffer

:tabdo {cmd} - run {cmd} in each tab

:argdo {cmd} - run {cmd} in each file in an argument list

I want to thank Andrew again for his submission.  If you have a vim tip that you’d like to share feel free to submit it via my contact page.

If this site has been useful, please consider participating in the Fundraiser.

Other Points of Interest

  • No Related Post

Comments

3 Responses to “Vim Tip of the Week : Oct 5th, 2007”

  1. Elaine on October 5th, 2007 12:09 pm

    Nice one. Thanks.

  2. Elaine on October 5th, 2007 12:11 pm

    I hit the SU icon and Stumbleupon was telling me Page Not Found. Never seen that before.

  3. jobieadobe on July 17th, 2008 4:01 pm

    same page not found

Leave a Comment




    Subscribe to the RSS feed!


    subscribe to the ubuntu tutorials RSS feed

    Ubuntu Tutorials Fundraiser


    Please Donate to
    Server Improvement

    Target amount: USD1,000.00
    Total Donations: USD328.00
    Amount Needed: USD672.00

    Thank you for your support!

    Click to Donate

    Polls



  • Blogroll

  • Ads by Google