0

When I enabled expandtab in vim by putting these in .vimrc:

set tw=4
set expandtab

Vim comverted every space typed by me to a newline character.
Like with the above settings whenever I type a new word and hit space
I get a new line.

Example:

What I want to type:
while (x < y):

What I get:
while
(x
<
y):
2
  • 1
    is there anything else in your vimrc than those 2 set lines? I've never seen or heard anything like this. What version are you using? What platform? Jan 4 '19 at 17:46
  • 1
    Its the textwidth line...
    – D. Ben Knoble
    Jan 4 '19 at 22:32
2

You set the textwith (tw) to 4. So Vim breaks the lines.

I guess you want shiftwidth:

set shiftwidth=4
set tabstop=4
set expandtab
1
  • That solved it.I wanted tab to be of 4 spaces.In a post I saw tw is for width of tab.Thanks.
    – Avm-x
    Jan 5 '19 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.