How can I break a paragraph into sentences with Vim?












3














By breaking into sentences I mean that each new sentence should start with a new line.



How to repeat )i<CR><Esc> to the end of the paragraph }? (<CR> = Enter)



If I make a macro )i<CR><Esc> as "q", can I execute it until the end of the paragraph?










share|improve this question





























    3














    By breaking into sentences I mean that each new sentence should start with a new line.



    How to repeat )i<CR><Esc> to the end of the paragraph }? (<CR> = Enter)



    If I make a macro )i<CR><Esc> as "q", can I execute it until the end of the paragraph?










    share|improve this question



























      3












      3








      3


      1





      By breaking into sentences I mean that each new sentence should start with a new line.



      How to repeat )i<CR><Esc> to the end of the paragraph }? (<CR> = Enter)



      If I make a macro )i<CR><Esc> as "q", can I execute it until the end of the paragraph?










      share|improve this question















      By breaking into sentences I mean that each new sentence should start with a new line.



      How to repeat )i<CR><Esc> to the end of the paragraph }? (<CR> = Enter)



      If I make a macro )i<CR><Esc> as "q", can I execute it until the end of the paragraph?







      vim macros






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 21 '11 at 21:13









      peth

      7,13022338




      7,13022338










      asked Apr 26 '11 at 0:04









      kirill_igum

      59321028




      59321028






















          4 Answers
          4






          active

          oldest

          votes


















          2














          You can do a search and replace. I just wrote this out. It works, but you could probably do better.



          :%s/v[ ]*([^.]*.)/1r/g





          share|improve this answer





























            2














            vap:s/. /.^M/g




            • vap selects your current paragraph


            • :s/. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)






            share|improve this answer





























              0














              My solution, start in normal mode and type:



              vip:'<,'>s/n/ /|'<,'>s/([.?!])s/1r/g


              Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.



              The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.



              This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.






              share|improve this answer





























                0














                I found that there is a very easy way of doing this using
                vim-macros.




                • First in normal mode press q, then any key, suppose that key is
                  a. So you will see something at the bottom as recording @a.

                • Now follow the key-sequence as 0)i<cr><esc>q Now your macro is
                  recorded. This will break the paragraph at . .

                • Now, repeat this macro as many times by pressing
                  N@a in normal mode, where N is any number.


                Note: You can choose any alphanumeric character to store your macro than a, this macro breaks the line at ., you can choose any column just replace . by any N of your choice.






                share|improve this answer























                  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%2f275364%2fhow-can-i-break-a-paragraph-into-sentences-with-vim%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  2














                  You can do a search and replace. I just wrote this out. It works, but you could probably do better.



                  :%s/v[ ]*([^.]*.)/1r/g





                  share|improve this answer


























                    2














                    You can do a search and replace. I just wrote this out. It works, but you could probably do better.



                    :%s/v[ ]*([^.]*.)/1r/g





                    share|improve this answer
























                      2












                      2








                      2






                      You can do a search and replace. I just wrote this out. It works, but you could probably do better.



                      :%s/v[ ]*([^.]*.)/1r/g





                      share|improve this answer












                      You can do a search and replace. I just wrote this out. It works, but you could probably do better.



                      :%s/v[ ]*([^.]*.)/1r/g






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Apr 26 '11 at 0:12









                      Dan Loewenherz

                      24817




                      24817

























                          2














                          vap:s/. /.^M/g




                          • vap selects your current paragraph


                          • :s/. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)






                          share|improve this answer


























                            2














                            vap:s/. /.^M/g




                            • vap selects your current paragraph


                            • :s/. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)






                            share|improve this answer
























                              2












                              2








                              2






                              vap:s/. /.^M/g




                              • vap selects your current paragraph


                              • :s/. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)






                              share|improve this answer












                              vap:s/. /.^M/g




                              • vap selects your current paragraph


                              • :s/. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 2 '11 at 3:44









                              chisophugis

                              1585




                              1585























                                  0














                                  My solution, start in normal mode and type:



                                  vip:'<,'>s/n/ /|'<,'>s/([.?!])s/1r/g


                                  Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.



                                  The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.



                                  This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.






                                  share|improve this answer


























                                    0














                                    My solution, start in normal mode and type:



                                    vip:'<,'>s/n/ /|'<,'>s/([.?!])s/1r/g


                                    Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.



                                    The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.



                                    This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.






                                    share|improve this answer
























                                      0












                                      0








                                      0






                                      My solution, start in normal mode and type:



                                      vip:'<,'>s/n/ /|'<,'>s/([.?!])s/1r/g


                                      Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.



                                      The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.



                                      This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.






                                      share|improve this answer












                                      My solution, start in normal mode and type:



                                      vip:'<,'>s/n/ /|'<,'>s/([.?!])s/1r/g


                                      Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.



                                      The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.



                                      This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered May 21 '11 at 21:34









                                      Heptite

                                      14.7k54157




                                      14.7k54157























                                          0














                                          I found that there is a very easy way of doing this using
                                          vim-macros.




                                          • First in normal mode press q, then any key, suppose that key is
                                            a. So you will see something at the bottom as recording @a.

                                          • Now follow the key-sequence as 0)i<cr><esc>q Now your macro is
                                            recorded. This will break the paragraph at . .

                                          • Now, repeat this macro as many times by pressing
                                            N@a in normal mode, where N is any number.


                                          Note: You can choose any alphanumeric character to store your macro than a, this macro breaks the line at ., you can choose any column just replace . by any N of your choice.






                                          share|improve this answer




























                                            0














                                            I found that there is a very easy way of doing this using
                                            vim-macros.




                                            • First in normal mode press q, then any key, suppose that key is
                                              a. So you will see something at the bottom as recording @a.

                                            • Now follow the key-sequence as 0)i<cr><esc>q Now your macro is
                                              recorded. This will break the paragraph at . .

                                            • Now, repeat this macro as many times by pressing
                                              N@a in normal mode, where N is any number.


                                            Note: You can choose any alphanumeric character to store your macro than a, this macro breaks the line at ., you can choose any column just replace . by any N of your choice.






                                            share|improve this answer


























                                              0












                                              0








                                              0






                                              I found that there is a very easy way of doing this using
                                              vim-macros.




                                              • First in normal mode press q, then any key, suppose that key is
                                                a. So you will see something at the bottom as recording @a.

                                              • Now follow the key-sequence as 0)i<cr><esc>q Now your macro is
                                                recorded. This will break the paragraph at . .

                                              • Now, repeat this macro as many times by pressing
                                                N@a in normal mode, where N is any number.


                                              Note: You can choose any alphanumeric character to store your macro than a, this macro breaks the line at ., you can choose any column just replace . by any N of your choice.






                                              share|improve this answer














                                              I found that there is a very easy way of doing this using
                                              vim-macros.




                                              • First in normal mode press q, then any key, suppose that key is
                                                a. So you will see something at the bottom as recording @a.

                                              • Now follow the key-sequence as 0)i<cr><esc>q Now your macro is
                                                recorded. This will break the paragraph at . .

                                              • Now, repeat this macro as many times by pressing
                                                N@a in normal mode, where N is any number.


                                              Note: You can choose any alphanumeric character to store your macro than a, this macro breaks the line at ., you can choose any column just replace . by any N of your choice.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Dec 1 at 12:19

























                                              answered Dec 1 at 11:28









                                              Galilean

                                              12




                                              12






























                                                  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.





                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                  Please pay close attention to the following guidance:


                                                  • 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%2f275364%2fhow-can-i-break-a-paragraph-into-sentences-with-vim%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

                                                  Plaza Victoria

                                                  Puebla de Zaragoza

                                                  Musa