Vim searching through all existing buffers

前端 未结 8 663
刺人心
刺人心 2021-02-01 13:23

When dealing with a single file, I\'m used to:

/blah
do some work
n
do some work
n
do some work

Suppose now I want to search for some pattern o

8条回答
  •  旧时难觅i
    2021-02-01 14:21

    Use the bufdo command.

    :bufdo command
    

    :bufdo command is roughly equivalent to iterating over each buffer and executing command. For example, let's say you want to do a find and replace throughout all buffers:

    :bufdo! %s/FIND/REPLACE/g
    

    Or let's say we want to delete all lines of text that match the regex "SQL" from all buffers:

    :bufdo! g/SQL/del
    

    Or maybe we want to set the file encoding to UTF-8 on all the buffers:

    :bufdo! set fenc=utf-8
    

    The above can be extrapolated for Windows (:windo), Tabs (:tabdo), and arguments (:argdo). See help on :bufdo for more information.

提交回复
热议问题