5

Wrap mode, if a paragraph has multiple rows, when it reaches the window at the top, and then I press Ctrl+E, this paragraph will disappear completely. Is there a way to making it only to reduce the top line rather than the entire paragraph?

See as the screen changes too sudden, I often can not find the location.

3 Answers3

4

for going pseudo-linewise in wraps you can change:

 noremap j gj
 noremap k gk

and add

set scrolloff = 3   " so you always have 3 lines on bottom and top or 
set scrolloff = 999 " to have the cursor(line) always in the middle 

and for finding the position put this in your .vimrc

set cursorline
if &term =~ "xterm\\|rxvt"
    " use a green cursor in insert mode
    let &t_SI = "\<Esc>]12;green\x7"
    " use an orange cursor otherwise
    let &t_EI = "\<Esc>]12;orange\x7"
    silent !echo -ne "\033]12;orange\007"
    " reset cursor when vim exits
    autocmd VimLeave * silent !echo -ne "\033]12;white\007"
    " use \003]12;gray\007 for gnome-terminal
endif

it makes the cursor green in insert mode and orange otherwise - those \<esc>]12;green\x7 are just to tell the terminal it should do that - in the language of australopithici or something, because that's how old terminals are ;-).

and this in your .gvimrc

highlight Cursor guifg=black guibg=DarkOrange
highlight iCursor guifg=black guibg=Green
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait0

well the last three lines are not necessary but i dislike blinking

epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
  • 1
    PS. I wanted to add - i don't like wraps, restricting to 80 characters or less is still common practice. when programming `an error occurred on line 79` could mean in the 800 characters on line 79 there is an error, and finding that is less easy than on a 100 character line. for acceptable indentation you have to patch vim - so you see I don't like wraps. – epsilonhalbe Jun 29 '12 at 07:58
  • 1
    Thank you for your answer. But even color it, reading in vim is still a bad experience. 80 chars is fit for coding but not normal writing. I have found that this problem couldn't fix for ever. http://stackoverflow.com/questions/8369021/in-vim-how-to-scroll-continuously-by-screen-lines-when-wrapping-is-enabled – user1490479 Jun 29 '12 at 08:10
  • what do you miss when reading? I know quite sure it displays most of unicode characters provided the right font. I can change colorschemes so my eyes don't hurt. I like reading in vim. – epsilonhalbe Jun 29 '12 at 08:16
  • It can't scroll smoothly when there are many paragraphs with multiple rows, I don't think keyboard is better than mouse while reading. – user1490479 Jun 29 '12 at 08:29
  • ahh i tried it with wrapped lines - now i see your problem. maybe http://stackoverflow.com/questions/4064651/what-is-the-best-way-to-do-smooth-scrolling-in-vim may help – epsilonhalbe Jun 29 '12 at 10:36
  • You could map an Fn key to """:set wrap!""" to toggle wrapping on/off when it's a problem. (I'm use to the @@@@ lines at the bottom of my Vim screen) In addition to: gj & gk there is and . As a bonus this will set you to the beginning or end of the logical line, even within Insert Mode, very handy sometimes. Also, you can set your cursorline in .vimrc with this line: """autocmd InsertEnter,InsertLeave * set cursorline!""" look at your help file ''':h cursorline""" you can modify the line to bold, underline, change from color to color, change background color etc. – user12711 Feb 07 '22 at 01:28
3

The question is asked very often and the answer is always "you can't".

It's possible to move the cursor "virtual line" by "virtual line" inside a wrapped line with gj and gk but it doesn't really help with the scrolling problem: Vim can't display only x "virtual lines" of a wrap.

romainl
  • 186,200
  • 21
  • 280
  • 313
0

As of Vim 9, use :set smoothscroll. From :help smoothscroll:

            *'smoothscroll'* *'sms'* *'nosmoothscroll'* *'nosms'*
'smoothscroll' 'sms'    boolean  (default off)
            local to window
    Scrolling works with screen lines.  When 'wrap' is set and the first
    line in the window wraps part of it may not be visible, as if it is
    above the window. "<<<" is displayed at the start of the first line,
    highlighted with |hl-NonText|.
    NOTE: only partly implemented, currently works with CTRL-E, CTRL-Y
    and scrolling with the mouse.
sam
  • 3,399
  • 4
  • 36
  • 51