mNo edit summary |
(Alternate map for ZC: :bo vs<cr>Ljzt:setl scb<cr><c-w>p:setl scb<cr>) |
||
Line 43: | Line 43: | ||
</pre> |
</pre> |
||
+ | |||
+ | Yet another keymap to solve this problem (other than the solution above this one doesn't set scrolloff though, so you might want to set that as in the aforementioned keymap): |
||
+ | |||
+ | <pre> |
||
+ | noremap <silent> ZC :bo vs<cr>Ljzt:setl scb<cr><c-w>p:setl scb<cr> |
||
+ | </pre> |
||
+ | |||
+ | This will_ |
||
+ | |||
+ | <pre> |
||
+ | :bo vs<cr> " Split the window vertically, make sure the new window is on the right |
||
+ | Lj " Move the cursor to the first line on the next page (this requires scrolloff to be 0) |
||
+ | zt " Scroll that line to the top |
||
+ | :setl scb<cr> " Set scrollbind |
||
+ | <c-w>p " Return to the previous window |
||
+ | :setl scb<cr> " Set scrollbind |
||
+ | </pre> |
||
+ | |||
[[Category:Usage]] |
[[Category:Usage]] |
Revision as of 10:57, 20 February 2009
View text file in two columns
Large wide monitors can be utilized better if text can be viewed in multiple columns.
The idea is to make wide widow (132, 160 or even more characters wide), then split it vertically, view 2 consequtive pages of the same text in left and right split widows and, finally, scrollbind them together to keep them synchronized.
This can be accomplished by issuing the following commands:
" view file in 2 columns set noscrollbind set nowrap normal mb50%zz vert split exe "normal Lma\<c-w>l'azt" set scrollbind exe "normal \<c-w>h" set scrollbind
Here is a macro you can map to:
" display current file in two columns noremap<silent> ZC :<C-U>let @z=&so<CR>:set so=0<CR>maHmz:set noscb<CR> \:vs<CR><C-W>wLzt:set scb<CR><C-W>p:set scb<CR> \`zzt`a:let &so=@z<CR>
Replace ZC with your mapping of choice. This will:
:<C-U>let @z=&so " enter the command line, clear it, and save the current 'scrolloff' in register z :set so=0 " set scrolloff to 0 so the cursor can get to the edge of the page maHmz " save cursor position using marks a and z so we can get back later :set noscb " reset 'scrollbind' so we can scroll in the new window :vs<CR><C-W>w " split a vertical window and switch to it Lzt " move to the bottom and scroll it to the top :set scb<CR><C-W>p:set scb<CR> " scrollbind both windows `zzt`a:let &so=@z " restore cursor position and 'scrolloff'
Yet another keymap to solve this problem (other than the solution above this one doesn't set scrolloff though, so you might want to set that as in the aforementioned keymap):
noremap <silent> ZC :bo vs<cr>Ljzt:setl scb<cr><c-w>p:setl scb<cr>
This will_
:bo vs<cr> " Split the window vertically, make sure the new window is on the right Lj " Move the cursor to the first line on the next page (this requires scrolloff to be 0) zt " Scroll that line to the top :setl scb<cr> " Set scrollbind <c-w>p " Return to the previous window :setl scb<cr> " Set scrollbind