Vim joining lines during wraping

4

I am using formatoptions to format my files. But if I have a new line character in my tex file, Vim joins the lines, removing this character. How to define in Vim the hard wraping without joining lines?

UPDATE:

I can observe this when I execute the following commands

ggVGgq

user14416

Posted 2013-05-08T18:06:08.510

Reputation: 298

1That's what that sequence of commands is supposed to do. If you want to wrap lines longer than 'textwidth' without joining any lines, use this instead: :g/./normal gqq That will execute the gqq (format this line) command on each line in your file individually. – garyjohn – 2013-05-08T22:35:19.760

Answers

1

It is not related to formatoptions. It is because you execute formatting on the whole file. To avoid joining you need to execute it on each line alone. For this you can use the following command:

    :%normal gqq

Yuki

Posted 2013-05-08T18:06:08.510

Reputation: 176

0

Do you have a and w in your 'formatoptions' setting? If so, try this:

:set formatoptions-=a formatoptions-=w

See:

:help fo-table

Heptite

Posted 2013-05-08T18:06:08.510

Reputation: 16 267

This is the line from my vimrc set formatoptions=t. – user14416 – 2013-05-08T19:20:36.387

1@user14416: Unless you have a in your 'formatoptions', Vim does not join lines unless you tell it to. Since you don't have a in your 'formatoptions', you, or one of your plugins, is telling Vim to join those lines. To discover what is happening so that your lines are not joined when you don't want them to be, we need more information, including an example of the actual text you are editing and exactly what you are doing when you observe the lines being joined. – garyjohn – 2013-05-08T19:38:54.697

@Heptite See my update. – user14416 – 2013-05-08T19:56:46.613

@Heptite I tried the same sequence of commands with vimrc of one line set fo=t and the same result. So it is not plugins. – user14416 – 2013-05-08T20:54:04.307

1To whoever voted this answer down, that was really uncalled for and I hope you'll reconsider. Heptite provided a reasonable answer. It's not his fault that the question was next to impossible to answer correctly at first given the lack of information in the original version. He should not be penalized for making a good attempt. – garyjohn – 2013-05-08T22:43:18.823