You're welcome. If you use windo and tabdo a lot, these versions might interest you. They work the same as the originals, but will restore your current window and tab after they're done. For example, if you execute ':windo set nu!', you'll end up in the last window you have open in the current tab; however, if you execute ':Windo set nu!', it will leave you in the same window as where you started.
You can use Tabdo and Windo just like the regular versions (I never use the built-in versions any more, to be honest):
function! TabDo( command )
let currTab = tabpagenr()
execute 'tabdo ' . a:command
silent! execute currTab . 'tabnext'
endfunction
com! -nargs=+ -complete=command Tabdo call TabDo( <q-args> )
" Just like Tabdo except that it disables all autocommands for super fast processing.
function! TabDoFast( command )
noautocmd call TabDo( a:command )
endfunction
com! -nargs=+ -complete=command Tabdofast noautocmd call TabDo(<q-args>)
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
silent! execute currwin . 'wincmd w'
endfunction
com! -nargs=+ -complete=command Windo call WinDo(<q-args>)
" Just like Windo except that it disables all autocommands for super fast processing.
function! WinDoFast( command )
noautocmd call WinDo( a:command )
endfunction
com! -nargs=+ -complete=command Windofast noautocmd call WinDo(<q-args>)
let currTab = tabpagenr()
execute 'tabdo ' . a:command
silent! execute currTab . 'tabnext'
endfunction
com! -nargs=+ -complete=command Tabdo call TabDo( <q-args> )
" Just like Tabdo except that it disables all autocommands for super fast processing.
function! TabDoFast( command )
noautocmd call TabDo( a:command )
endfunction
com! -nargs=+ -complete=command Tabdofast noautocmd call TabDo(<q-args>)
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
silent! execute currwin . 'wincmd w'
endfunction
com! -nargs=+ -complete=command Windo call WinDo(<q-args>)
" Just like Windo except that it disables all autocommands for super fast processing.
function! WinDoFast( command )
noautocmd call WinDo( a:command )
endfunction
com! -nargs=+ -complete=command Windofast noautocmd call WinDo(<q-args>)
On Sun, Nov 29, 2020 at 1:19 PM <tuxic@posteo.de> wrote:
Hi Salman,
OH YES! :) Exactly what I have searched for! Thanks a lot!
Cheers!
Meino
On 11/29 01:15, Salman Halim wrote:
> If you're duplicating keystrokes you might hit in normal mode, the command
> is :normal, so something like might work:
>
> tabdo windo normal dd
> tabdo windo normal Ihello<esc>
>
> --
>
> Salman
>
> On Sun, Nov 29, 2020, 13:10 <tuxic@posteo.de> wrote:
>
> > Hi Tim,
> >
> > thanks for your reply!
> >
> > Is there a more general way to acchieve this?
> >
> > If I would had asked:
> > "I have a command, which is known by its shortcut only: How can I
> > execute this command for each tab or each window by using tabdo or
> > window respectively?"
> >
> > Is there an answer even if the command itsself is not know first hand?
> >
> > Cheers!
> > Meino
> >
> >
> >
> > On 11/27 09:59, Tim Chase wrote:
> > > On 2020-11-27 07:44, tuxic@posteo.de wrote:
> > > > suppose I want to delete a line in each window or tab I currently
> > > > have in my vim...how can I do a
> > > >
> > > > windo
> > > > or
> > > >
> > > > tabdo
> > > >
> > > > combined with 'dd' (and I am too lazy to lookup the command name
> > > > in the help for each shortcut I want to use this way... ;)
> > >
> > > Well for the "dd" case, that's the same as the ex ":d" command so you
> > > can do
> > >
> > > :windo d
> > > :tabdo d
> > >
> > > assuming that the cursor is positioned on the right line. If it's a
> > > particular line like the first or last line in the file, you can
> > > specify that:
> > >
> > > :windo 1d
> > > :windo $d
> > >
> > > or if it's all lines matching a pattern,
> > >
> > > :windo g/pattern/d
> > >
> > > -tim
> > >
> > >
> > > --
> > > --
> > > You received this message from the "vim_use" maillist.
> > > Do not top-post! Type your reply below the text you are replying to.
> > > For more information, visit http://www.vim.org/maillist.php
> > >
> > > ---
> > > You received this message because you are subscribed to the Google
> > Groups "vim_use" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> > an email to vim_use+unsubscribe@googlegroups.com.
> > > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/vim_use/20201127095949.1f6b9036%40bigbox.attlocal.net
> > .
> > >
> >
> > --
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to vim_use+unsubscribe@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/vim_use/20201129181017.huebjeeyumb7crfq%40solfire
> > .
> >
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEd7zKr0-k3PJ9hN9ftnvXC%3D11ug7M0ocZTOWv56YH6vYA%40mail.gmail.com.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201129181918.k56bsfr6xhpyyg6u%40solfire.
Salman
I, too, shall something make and glory in the making.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEfw0HTjiOjycNt%2BeHDUuTXagg78iMu8vpS6-ExPaqRk4g%40mail.gmail.com.
No comments:
Post a Comment