Cursor behavior in insert mode (soft wrap)

37 views
Skip to first unread message

hcf

unread,
Mar 14, 2023, 7:18:33 AM3/14/23
to vim_use

I'm trying to configure a desired behavior when soft-wraping text.

I only have three lines in my .vimrc

set nocompatible 
set wrap 
set linebreak


This work as I would expect, except from the moment when vim actually wraps text. When I write a word that takes me to the end of the line, the cursor jumps to the next line while the word stays on the previous line. If I then press ‹space›, the last word moves to the same line as the cursor. I would like the cursor to stay on the same line as the last word when typing.

Basically, I think I'm trying to acomplish what is standard word-wrap and insert in other editors/word processors.

Is there a way to accomplish this? Is this due to terminal settings?


(I have posted the same question here two months ago, but no answer yet)

Best regards
hcf

Steve Martin

unread,
Mar 15, 2023, 2:45:45 AM3/15/23
to vim_use
I'm not entirely certain this is a VIM issue. I cannot reproduce what you describe in my VIM.

However, first of all what do you have "wrapmargin" set to? Also, do you change "breakat" from the standard set of characters to break on?

hcf

unread,
Mar 15, 2023, 4:40:37 AM3/15/23
to vim_use
I literally only had the three lines in my .vimrc. Setting wrapmargin to a non-zero value changed the cursor behavior. It now behaves as expected in insert mode. Thanks! But it also changed how vim reflows the visual display. With wrapmargin=0 vim will reflow my paragrahs fine when i delete words  in the begin of the paragraph. This is what I want to achieve.  With Wrapmargin set to a positive value, Vim will not reflow my visual display when I delete words early in a paragraph.

hcf

unread,
Mar 15, 2023, 5:38:54 AM3/15/23
to vim_use
I might have been to fast on the trigger here. From :help linebreak it seems to me that wrapmargin turns on "hard wrap" and inserts eol-characters.

Steve Martin

unread,
Mar 16, 2023, 2:35:24 AM3/16/23
to vim_use
So the question is what exactly do you want to happen? When I have linebreak and wrapmagin=0 I get no hard breaks.

hcf

unread,
Mar 16, 2023, 6:06:15 AM3/16/23
to vim_use
Same result here. Linebreak and wrapmargin=0 gives no hard breaks. Wrapmargin set to a nonzero value gives hard breaks.

But the original problem persists even with wrapmargin=0: The cursor behavior in insert mode is «strange» when moving to the next line.  The cursor moves to the next line while the last word stays on the previous line. If <space> is the next character i type, the last word on the previous line jumps to the next line.
Reply all
Reply to author
Forward
0 new messages