Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying an option to all opened files in Vim

Tags:

I do a vimdiff on 2 files. Now if I want to wrap 2 files then I need to apply :set wrap 2 times to each file separately.

Is there any way I can apply set wrap to both of them simultaneously without running same command twice?

like image 742
ravi Avatar asked Aug 30 '11 14:08

ravi


People also ask

Can you open more than one file in Vim without running a second instance?

You can open multiple files at the start of the Vim editing session from the command line, or at any time from inside the Vim editing session.

What does set do in Vim?

There are two ways to use the Vim setting options: 1. Enable the options for an individual file inside the Vim session using :set Open the desired file in Vim, type any option using the :set command in the Normal mode, and press Enter.

How do I switch multiple files in Vim?

Using windows. Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.

What is a Vim buffer?

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

windo does exactly what you want:

:windo set wrap 

If you have multiple tabs, there is an equivalent tabdo to handle that case.

:tabdo set wrap 
like image 100
holygeek Avatar answered Oct 12 '22 21:10

holygeek