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

  • 1
    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

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

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

:set formatoptions-=a formatoptions-=w


:help fo-table
  • This is the line from my vimrc set formatoptions=t.
    – user14416
    May 8 '13 at 19:20
  • 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
    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
  • 1
    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

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.