Zhang Weiwu wrote:

Hello. I often use keyboard shortcut 'z'+<right> to move the viewport to +1 position, that is, hide the first character of each line. However, whenever I move to an empty line, the viewport reset to +0 position - a reasonable behaviour to make sure the cursor displayed. Is there a way to fix the vieweport to +1 always?

A weird question isn't it? You may ask why such need? Here is the story:

    I work on a 1280x800 console, with 8-pixel-wide font it is exactly
    160 columns, just enough to hold two 80-column source file
    side-by-side. I am confort to work with vertical split of two,
    usually one side the source code being called, the other side where
    it is called from. My conding convention requires 80-columns per
    line.

    The problem is that the vertical split bar (fillchars=vert:|) takes
    one column off, that is, 80-columns and 79-columns I have - there is
    no way to remove vertical split bar, even I don't need it (the
    indent being a clear visual cue). The code is tight, won't make do
    with 79-columns.

    The workaround is to set nowrap, and use 'z'+<right> to move the
    viewport - which hides away the 1st character of each line. In each
    file there is only one non-space character as the 1st in line: 'c',
    and it is never edited, as in:

    class ClassName(...) # 'c' is the only character ever on 1st column
        content_of_the_class ....

    The workaround doesn't work with the lines that has zero characters:
    empty lines, in which case the cursor stops on the 1st position, and
    thus cancelling previous 'z'+<right> keyboard command.

    Alternative solution is to try 7-pixel wide font, and I tried a
    while: it is hard to eyes.


The following will help:  (use zp and zP instead of p, P, though)

" ---------------------------------------------------------------------
" Settings: {{{2
set ve=all nosol

" ---------------------------------------------------------------------
" Maps: {{{2
nno <silent> zp    :call <SID>Zput("p")<CR>
nno <silent> zP    :call <SID>Zput("P")<CR>

" ---------------------------------------------------------------------
" s:Zput: does a put but retains cursor position {{{2
fun! s:Zput(put)
  let save_lz=&lz
  set lz
  let zp=virtcol(".")-1
  if zp > 0
    exe "norm ".a:put."0".zp."l"
  else
    exe "norm ".a:put
  endif
  let &lz= save_lz
endfun
" ---------------------------------------------------------------------

Regards,
Chip Campbell


--
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to