Hard line wrapping in vim without joining in insert mode












-1















Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.



This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type



a


Still in insert mode, I hit return and type 'b'. What appears is not



a
b


but



a b


When I set



set: formatoptions-=a


This unintended behavior stops, as do the intended line breaks.



I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!










share|improve this question



























    -1















    Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.



    This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type



    a


    Still in insert mode, I hit return and type 'b'. What appears is not



    a
    b


    but



    a b


    When I set



    set: formatoptions-=a


    This unintended behavior stops, as do the intended line breaks.



    I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!










    share|improve this question

























      -1












      -1








      -1








      Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.



      This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type



      a


      Still in insert mode, I hit return and type 'b'. What appears is not



      a
      b


      but



      a b


      When I set



      set: formatoptions-=a


      This unintended behavior stops, as do the intended line breaks.



      I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!










      share|improve this question














      Very new to vim. Found a useful post here that explains how to get automatic hard line breaks while in insert mode.



      This had unintended consequences. For example, suppose I start a new .txt file. While in insert mode, I type



      a


      Still in insert mode, I hit return and type 'b'. What appears is not



      a
      b


      but



      a b


      When I set



      set: formatoptions-=a


      This unintended behavior stops, as do the intended line breaks.



      I'd like to keep the latter without the former. There seemed to be a related question that focuses on the same issue, but for re-formatting existing text. Any help would be greatly appreciated. Thanks!







      vim text-formatting word-wrap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 13 '18 at 2:45









      GregGreg

      31




      31






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.



          :help auto-format offers good advice to make this workable. In particular:





          • You need to properly define paragraphs. The simplest is paragraphs that are
            separated by a blank line. When there is no separating blank line, consider
            using the 'w' flag and adding a space at the end of each line in the
            paragraphs except the last one.




          So, :setlocal formatoptions+=w and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)






          share|improve this answer
























          • Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

            – Greg
            Dec 15 '18 at 22:20











          • Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

            – Ingo Karkat
            Dec 15 '18 at 22:25











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1383169%2fhard-line-wrapping-in-vim-without-joining-in-insert-mode%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.



          :help auto-format offers good advice to make this workable. In particular:





          • You need to properly define paragraphs. The simplest is paragraphs that are
            separated by a blank line. When there is no separating blank line, consider
            using the 'w' flag and adding a space at the end of each line in the
            paragraphs except the last one.




          So, :setlocal formatoptions+=w and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)






          share|improve this answer
























          • Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

            – Greg
            Dec 15 '18 at 22:20











          • Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

            – Ingo Karkat
            Dec 15 '18 at 22:25
















          0














          Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.



          :help auto-format offers good advice to make this workable. In particular:





          • You need to properly define paragraphs. The simplest is paragraphs that are
            separated by a blank line. When there is no separating blank line, consider
            using the 'w' flag and adding a space at the end of each line in the
            paragraphs except the last one.




          So, :setlocal formatoptions+=w and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)






          share|improve this answer
























          • Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

            – Greg
            Dec 15 '18 at 22:20











          • Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

            – Ingo Karkat
            Dec 15 '18 at 22:25














          0












          0








          0







          Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.



          :help auto-format offers good advice to make this workable. In particular:





          • You need to properly define paragraphs. The simplest is paragraphs that are
            separated by a blank line. When there is no separating blank line, consider
            using the 'w' flag and adding a space at the end of each line in the
            paragraphs except the last one.




          So, :setlocal formatoptions+=w and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)






          share|improve this answer













          Auto-formatting first sounds like a great feature, but it has many caveats, so I personally find it helpful only for very few editing tasks.



          :help auto-format offers good advice to make this workable. In particular:





          • You need to properly define paragraphs. The simplest is paragraphs that are
            separated by a blank line. When there is no separating blank line, consider
            using the 'w' flag and adding a space at the end of each line in the
            paragraphs except the last one.




          So, :setlocal formatoptions+=w and then it'll work as you expect. (But each line inside a paragraph will end with a trailing space!)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 13 '18 at 9:32









          Ingo KarkatIngo Karkat

          17.3k22343




          17.3k22343













          • Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

            – Greg
            Dec 15 '18 at 22:20











          • Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

            – Ingo Karkat
            Dec 15 '18 at 22:25



















          • Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

            – Greg
            Dec 15 '18 at 22:20











          • Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

            – Ingo Karkat
            Dec 15 '18 at 22:25

















          Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

          – Greg
          Dec 15 '18 at 22:20





          Thank you very much!! Tried this and it worked great. The auto-format documentation was also very helpful -- will check there before asking questions in the future. Thanks again!

          – Greg
          Dec 15 '18 at 22:20













          Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

          – Ingo Karkat
          Dec 15 '18 at 22:25





          Alright, nice. Please don't forget to accept the answer (by clicking on the outlined checkmark next to it)!

          – Ingo Karkat
          Dec 15 '18 at 22:25


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1383169%2fhard-line-wrapping-in-vim-without-joining-in-insert-mode%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Список кардиналов, возведённых папой римским Каликстом III

          Deduzione

          Mysql.sock missing - “Can't connect to local MySQL server through socket”