RocketTwitch
RocketTwitch

Reputation: 295

Vim randomly adding new lines while in insert mode

I'm a fairly new Vim user and I'm coming across something that's very annoying and I haven't been able to find very much of anything on the web. When I enter insert mode in Vim and begin typing, the word I'm editing will be put on a newline instead of remaining at its original position. What are some places I can check to resolve this? I'll past my .vimrc but I don't see anything in there that may be causing an issue.

  1 " Turn on line numbers on the side
  2 :set number
  3
  4 " Adjust <Tab> button to be 4 chars long
  5 set softtabstop=4
  6 set shiftwidth=4
  7 set textwidth=4
  8 set expandtab
  9
 10 " Turning on syntax highlighting as adding a filetypes
 11 syntax on
 12 filetype on
 13
 14 " Remappings
 15 inoremap jk <ESC>
 16
 17 set scrolloff=5
 18
 19

Upvotes: 3

Views: 1512

Answers (1)

FDinoff
FDinoff

Reputation: 31419

You have a really low textwidth.

set textwidth=4

This should be set to something higher. With it set to 4 the size of the line will be at most 4 characters before vim tries to auto wrap it.

From :help 'textwidth'

                                                'textwidth' 'tw'
'textwidth' 'tw'        number  (default 0)
                        local to buffer
                        {not in Vi}
        Maximum width of text that is being inserted.  A longer line will be
        broken after white space to get this width.  A zero value disables
        this.  'textwidth' is set to 0 when the 'paste' option is set.  When
        'textwidth' is zero, 'wrapmargin' may be used.  See also
        'formatoptions' and ins-textwidth.
        When 'formatexpr' is set it will be used to break the line.
        NOTE: This option is set to 0 when 'compatible' is set.

From the context of the other settings being set did you mean 'tabstop'. (The size of a tab?)

set tabstop=4

Upvotes: 2

Related Questions