columnar-view code editing

classic Classic list List threaded Threaded
5 messages Options
kae
Reply | Threaded
Open this post in threaded view
|

columnar-view code editing

kae
Hi guys,
  I like to write my code in 80-character-width pages. When editing with
larger resolutions, this can mean that my code fills the left side of
the screen, and there's a load of space on the right.

Is there a way to break the screen into several pieces such that, say,
there are two columns visible, and deleting a line in the first column
causes the whole page to update, not just the current column?

I know it's possible to "freeze" parts of the page, but I think this is
different. To paraphrase using word processors as an example, I'd like
to be able to edit my files as if they were preformatted to be in
n-column form, where they are actually saved as plain text.

I hope that's not too confusing :)
Kae

Reply | Threaded
Open this post in threaded view
|

Re: columnar-view code editing

Tim Chase-2
> Is there a way to break the screen into several pieces such that, say,
> there are two columns visible, and deleting a line in the first column
> causes the whole page to update, not just the current column?

I've done this in the past, making use of the 'scrollbind' feature.

0) open your file
1) maximize your window
2) use the ":vsp" (vertical split) Ex command to split your
window vertically
3) make sure you're in the right-hand window (which depends on
your settings for 'splitright')
4) go forward a page or so (line up the views you want)
5) :set scrollbind
6) go to the first window (^W^W should do)
7) :set scrollbind

The windows should now be in lockstep with each other.  Deleting
in one doesn't update the other window's offset (though the
changes are implemented there) but if you've got scroll-bars, you
can use them to resynch the two (or unset 'scrollbind', adjust
accordingly, and reset 'scrollbind').

With enough screen realestate, you may be able to duplicate the
process with multiple columns, setting 'scrollbind' in each of them.

For more help, see

        :help vsp
        :he splitright
        :he 'scrollbind'
        :he 'scrollopt'

HTH,

-tim






Reply | Threaded
Open this post in threaded view
|

Re: columnar-view code editing

Charles E Campbell Jr
In reply to this post by kae
Quoting Kae Verens <[hidden email]>:

>   I like to write my code in 80-character-width pages. When editing with
> larger resolutions, this can mean that my code fills the left side of
> the screen, and there's a load of space on the right.
>
> Is there a way to break the screen into several pieces such that, say,
> there are two columns visible, and deleting a line in the first column
> causes the whole page to update, not just the current column?

Perhaps splitting is all you need...

:vsplit

You may find scrollbind of interest (see :help 'scb').  I use the following
command to toggle scrollbind on/off for all windows:

" ---------------------------------------------------------------------
" Scb: toggle all windows to/from scrollbind {{{2
com! -nargs=0 Scb call <SID>ScrollBindToggle()
fun! s:ScrollBindToggle()
  if &scb == 0
   let wn                 = winnr()
   let g:scrollbindtoggle = &sbo
   set sbo=ver,hor,jump
   windo set scb
   exe wn."wincmd w"
  else
   let wn   = winnr()
   let &sbo = g:scrollbindtoggle
   unlet g:scrollbindtoggle
   windo set noscb
   exe wn."wincmd w"
  endif
endfun

Usage:   :Scb

One trick with this:

:vsplit
ctrl-w l
ctrl-f
:Scb
ctrl-w h

will split your window vertically, make the right window active, scroll
down one page, scrollbind all open windows, and then make the left window
active again.  That way your two "columns" are one page apart, and should
stay that way.

Regards,
Chip Campbell


Reply | Threaded
Open this post in threaded view
|

Re: columnar-view code editing

John (Eljay) Love-Jensen
In reply to this post by kae
Hi Kae,

>Is there a way to break the screen into several pieces such that, say, there are two columns visible, and deleting a line in the first column causes the whole page to update, not just the current column?

I do that all the time!

Ctrl-W v
"Window Vertical split"

Ctrl-W s
"Window horizontal Split"

Ctrl-W Ctrl-W
"Cycle through windows"

Ctrl-W {hjkl motion}
"Focus on window as indicated by cursor motion"

Ctrl-W c
"Window Close" (the one with the current focus)

More information via help on Window commands:
:help ctrl-w

Enjoy,
--Eljay

kae
Reply | Threaded
Open this post in threaded view
|

Re: columnar-view code editing

kae
In reply to this post by Charles E Campbell Jr
[hidden email] wrote:

>Perhaps splitting is all you need...
>
>:vsplit
><snip stuff />
>
>will split your window vertically, make the right window active, scroll
>down one page, scrollbind all open windows, and then make the left window
>active again.  That way your two "columns" are one page apart, and should
>stay that way.
>  
>

Perfect.

Thanks, Chip!

Kae