Tip #133: Windo and Bufdo
tip karma |
Rating 8/5, Viewed by 1716
|
created: |
|
October 11, 2001 13:41 |
|
complexity: |
|
basic |
author: |
|
Salman Halim |
|
as of Vim: |
|
6.0 |
i like bufdo and windo but i don't like the fact that the commands end in a different window/buffer than from where i executed them. these versions (starts with a capital letter) will restore the current window or buffer when the command's done.
for example, to turn on line numbers everywhere, i use :Windo set nu -- :windo set nu does the trick also but leaves me in a different window than where i started.
" just like windo but restores the current window when it's done
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
execute currwin . 'wincmd w'
endfunction
com! -nargs=+ -complete=command Windo call WinDo(<q-args>)
" just like bufdo but restores the current buffer when it's done
function! BufDo(command)
let currBuff=bufnr("%")
execute 'bufdo ' . a:command
execute 'buffer ' . currBuff
endfunction
com! -nargs=+ -complete=command Bufdo call BufDo(<q-args>)
<<window zooming convenience |
View Source in IE6 using VIM >>
Additional Notes
|