Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - How to run a non normal mode command in all buffers?

I need to run this command :perldo s/assigned_to(?!_member|_role)/assigned_to_member/g in all open buffers. I'm using :perldo because the builtin vim regex (i.e. %s/foo/bar/g) isn't working with my negative lookahead for some reason.

Through my research I've found the :bufdo and :execute "normal <foo>" commands but I haven't yet figured out how to combine them.

Does anyone know how I would be able to run the perldo command on all my open buffers? Thanks!

like image 364
BenHohner Avatar asked Sep 04 '12 20:09

BenHohner


People also ask

How do I navigate between buffers in Vim?

Pressing Alt-F12 opens a window listing the buffers, and you can press Enter on a buffer name to go to that buffer. Or, press F12 (next) or Shift-F12 (previous) to cycle through the buffers.

How do I close all buffers in Vim?

Just put it to your . vim/plugin directory and then use :BufOnly command to close all buffers but the active one.

What does buffer mean in Vim?

A buffer is an area of Vim's memory used to hold text read from a file. In addition, an empty buffer with no associated file can be created to allow the entry of text. The :e filename command can edit an existing file or a new file.


1 Answers

What's wrong with:

:bufdo! perldo s/assigned_to(?!_member|_role)/assigned_to_member/g
like image 51
Zsolt Botykai Avatar answered Oct 13 '22 02:10

Zsolt Botykai