Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


I can observe this when I execute the following commands

share|improve this question
That'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 May 8 '13 at 22:35
up vote 1 down vote accepted

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
share|improve this answer

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

:set formatoptions-=a formatoptions-=w


:help fo-table
share|improve this answer
This is the line from my vimrc set formatoptions=t. – user14416 May 8 '13 at 19:20
@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 May 8 '13 at 19:38
@Heptite See my update. – user14416 May 8 '13 at 19:56
@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 May 8 '13 at 20:54
To 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 May 8 '13 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .