Wednesday, March 2, 2011

Re: Edit same in two windows same Vim session

Actually I didn't test this before I sent the message (sorry) and it
appears that Vim automatically does this when you edit the same file
in two windows in the same session.

On Mar 1, 8:48 pm, "Benjamin R. Haskell" <v...@benizi.com> wrote:
> On Tue, 1 Mar 2011, Colin Beighley wrote:
> > Hello,
>
> > I'm wondering if anyone knows of a way to edit the same file in two
> > windows in the same Vim session, where the file within the two windows
> > stays in sync with eachother.
>
> If you really just want two windows (with no other windows), it's
> particularly easy:
>
> :sp | windo se scb crb
>
> :sp[lit] splits the current buffer
> '|' (<bar>) separates two commands
> :windo does something over every window
> :se[t] sets a variable in each of those windows
> 'scb' is short for 'scrollbind'
> 'crb' is short for 'cursorbind'
>
> More info on each at:
>
> :help :split
> :help :bar
> :help :windo
> :help :set
> :help 'scrollbind'
> :help 'cursorbind'
>
> For two arbitrary windows, with possibly many other windows open, it's
> only slightly more complex, possibly with a better way to do it.
>
> :se scb crb | sp | se crb
>
> The second :se[t] command is necessary because the 'cursorbind' setting
> isn't copied through the :sp[lit].
>
> If you want vertical rather than horizontal splits, change the :sp[lit]
> commands to :vs[plit]'s:
>
> e.g.
> :se scb crb | vs | se crb
>
> :help :vsplit
>
> --
> Best,
> Ben

--
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

No comments: