Useful vim tricks - lmmx/devnotes GitHub Wiki

  • Chain :wn after another ex command in vim with | to "move on to the next file" (and just repeat the same thing), e.g. to do a replace all and move on:

    echo "hello world" > a.txt
    echo "hello? world?" > b.txt
    echo "helloooo world" > c.txt
    vim {a,b,c}.txt
    

    :%s/o/a/g | wn
    

    You might combine this with grep to find the files with the matching string:

    vim $(grep -r "o" | cut -d ":" -f 1 | sort | uniq)