1

Lets say for example, I have 3 files opened in split windows in vim. And I have to changes the access permissions to each of them, then one way to do it, is to move my cursor to individual split window & execute :!chmod 777 % The problem here is that I have to do execute this command 'n' number of times, for 'n' number of split windows opened. Is there an easier way, where this can be achieved by executing just single command from vim?

3

If you want to do that specifically for all split windows then windo is what you are looking for :h :windo

:[range]windo {cmd} Execute {cmd} in each window or if [range] is given
            only in windows for which the window number lies in
            the [range]. It works like doing this: >
                CTRL-W t
                :{cmd}
                CTRL-W w
                :{cmd}
                etc.

So you can use this:

:windo !chmod +x %

But you might also be looking for :h :bufdo or :h arglist

2
:help :windo
:help setfperm()

Map this:

1,3windo call setfperm(expand("%"),"rwxrrxrrx")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy