11

When using :set wrap in vi/vim, the contents of an entire wrapped line are placed in the display buffer upon moving the cursor into a new line, even when navigating through a file by display line (gj/gk) as opposed to real line (j/k). For example, if a line is wrapped over 5 screen lines and is currently outside the display buffer, the buffer will jump by 5 lines when navigating into this line to force the entire line to fit in the screen. Is there a way to disable this behavior? Note that set display+=lastline will allow the display of partial lines when a wrapped line is forced off the screen by navigating away from the line, but this does not resolve the buffer jumps that occur when navigating into a line that was initially outside the buffer.

Clarification: In case the above description is nebulous, the gist is that I would like to be able to scroll smoothly in vim with line wrapping enabled such that lines will be partially displayed off the screen rather than obligatorily being displayed in their entirety.

7
  • 1
    Could you confirm that what you mean is: you want part of the wrapped portion of the line to be off-display and be able to scroll smoothly? Vim shows lines entirely when 'wrap' is on I'm afraid
    – Benoit
    Dec 8, 2011 at 8:12
  • Precisely. I take it there is no way to override this behavior of showing wrapped lines in their entirety while scrolling? Thank you.
    – user001
    Dec 8, 2011 at 8:25
  • 1
    Not that I know. Wait for answers though, nobody knows what Vim can do.
    – Benoit
    Dec 8, 2011 at 8:33
  • 1
    agree with @Benoit. Not possible as far as I know. Dec 8, 2011 at 9:05
  • 1
    There is currently a discussion on the vim_dev mailing list on this topic. It seems you aren't the only one with this request. Dec 8, 2011 at 12:01

2 Answers 2

1

Not a complete answer, but maybe a lead. There's scroll option. Help for that option reads, among other things:

{Vi is a bit different: 'scroll' gives the number of screen lines instead of file lines, makes a difference when lines wrap}

1
  • Thanks, that is helpful. The <Ctrl-E> (down) and <Ctrl-Y> (up) key combinations give the basic behavior that I want. If there is a way to detect if the cursor is on the top or bottom line of the window, then a temporary solution would involve conditionally mapping the up and down arrow keys to <Ctrl-Y>gk and <Ctrl-E>gj, respectively. When the cursor is not on the top or bottom line of the window, then mapping them to gk and gj is necessary (the else statement in the conditional). Is there a simple way to detect whether the cursor is on the top or bottom line of the current window?
    – user001
    Dec 13, 2011 at 7:47
0

in normal mode, you can jump between the displayed parts of a wrapped line by using gk and gj (g<up> or g<down>). This vim wikipage explains how to change the behaviour permanently.

2
  • 1
    Certainly, and I have mapped those behaviors to the directional arrow keys. However, this is different from the obligatory display of the entirety of a wrapped line upon navigating to that line. This behavior is independent of use of gj/gk or j/k. I would like to be able to partially navigate into a line that is initially out of the buffer (off the screen) without the entire wrapped line being displayed.
    – user001
    Dec 8, 2011 at 9:41
  • OK, then I misunderstood. Well, I guess your line is either wrapped, or it is not. What you'd want is something in between, but I think it's simply impossible.
    – jpjacobs
    Dec 8, 2011 at 9:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .