vi / vim abrumpt buffer movements within window

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.

user001

Posted 2011-12-08T07:34:19.120

Reputation: 2 074

1Could 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 – 2011-12-08T08:12:32.517

Precisely. I take it there is no way to override this behavior of showing wrapped lines in their entirety while scrolling? Thank you. – user001 – 2011-12-08T08:25:32.433

1Not that I know. Wait for answers though, nobody knows what Vim can do. – Benoit – 2011-12-08T08:33:29.140

1agree with @Benoit. Not possible as far as I know. – Fredrik Pihl – 2011-12-08T09:05:28.310

By the way, +1 for a very nice and useful question. – Benoit – 2011-12-08T10:09:04.230

1There is currently a discussion on the vim_dev mailing list on this topic. It seems you aren't the only one with this request. – Randy Morris – 2011-12-08T12:01:11.820

@RandyMorris: Thanks for letting me know about that. Are the transactions hosted on a sever for public viewing? – user001 – 2011-12-08T23:35:50.880

Answers

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}

thebodzio

Posted 2011-12-08T07:34:19.120

Reputation: 430

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 – 2011-12-13T07:47:40.153

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.

jpjacobs

Posted 2011-12-08T07:34:19.120

Reputation: 296

1Certainly, 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 – 2011-12-08T09:41:37.437

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 – 2011-12-08T09:57:43.817