How can I count the number of words in a file whilst editing the file in vim

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












20















I know I can use wc for counting characters, words and lines of files at the command line.



Is there any way I can can count the number of words while in vim?










share|improve this question


























    20















    I know I can use wc for counting characters, words and lines of files at the command line.



    Is there any way I can can count the number of words while in vim?










    share|improve this question
























      20












      20








      20


      4






      I know I can use wc for counting characters, words and lines of files at the command line.



      Is there any way I can can count the number of words while in vim?










      share|improve this question














      I know I can use wc for counting characters, words and lines of files at the command line.



      Is there any way I can can count the number of words while in vim?







      vim vi






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 18 '14 at 13:02









      Michael DurrantMichael Durrant

      15.9k44117183




      15.9k44117183




















          2 Answers
          2






          active

          oldest

          votes


















          21














          You can count words and lines inside vi using vi's own counter:



          Press g and then CTRL-g. Then the bottom line look for example like this:



          Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644


          Or use vi's method to call shell commands:



          :w !wc -w


          This calls the save (:w) command first and then wc -w and shows the output. Example:



          :w !wc -w
          344

          Press ENTER or type command to continue


          Press Enter to go back to vi.






          share|improve this answer























          • It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

            – mcepl
            Nov 17 '17 at 9:45



















          0














          Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.






          share|improve this answer























          • This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

            – Patrick Sanan
            Jan 9 at 19:04











          • I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

            – kemotep
            Jan 9 at 19:43










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f145289%2fhow-can-i-count-the-number-of-words-in-a-file-whilst-editing-the-file-in-vim%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          21














          You can count words and lines inside vi using vi's own counter:



          Press g and then CTRL-g. Then the bottom line look for example like this:



          Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644


          Or use vi's method to call shell commands:



          :w !wc -w


          This calls the save (:w) command first and then wc -w and shows the output. Example:



          :w !wc -w
          344

          Press ENTER or type command to continue


          Press Enter to go back to vi.






          share|improve this answer























          • It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

            – mcepl
            Nov 17 '17 at 9:45
















          21














          You can count words and lines inside vi using vi's own counter:



          Press g and then CTRL-g. Then the bottom line look for example like this:



          Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644


          Or use vi's method to call shell commands:



          :w !wc -w


          This calls the save (:w) command first and then wc -w and shows the output. Example:



          :w !wc -w
          344

          Press ENTER or type command to continue


          Press Enter to go back to vi.






          share|improve this answer























          • It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

            – mcepl
            Nov 17 '17 at 9:45














          21












          21








          21







          You can count words and lines inside vi using vi's own counter:



          Press g and then CTRL-g. Then the bottom line look for example like this:



          Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644


          Or use vi's method to call shell commands:



          :w !wc -w


          This calls the save (:w) command first and then wc -w and shows the output. Example:



          :w !wc -w
          344

          Press ENTER or type command to continue


          Press Enter to go back to vi.






          share|improve this answer













          You can count words and lines inside vi using vi's own counter:



          Press g and then CTRL-g. Then the bottom line look for example like this:



          Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644


          Or use vi's method to call shell commands:



          :w !wc -w


          This calls the save (:w) command first and then wc -w and shows the output. Example:



          :w !wc -w
          344

          Press ENTER or type command to continue


          Press Enter to go back to vi.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 18 '14 at 13:21









          chaoschaos

          35.3k773117




          35.3k773117












          • It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

            – mcepl
            Nov 17 '17 at 9:45


















          • It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

            – mcepl
            Nov 17 '17 at 9:45

















          It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

          – mcepl
          Nov 17 '17 at 9:45






          It is actually incorrect description of :w !<cmd> construct. It writes the current buffer to a pipe connected to the command. No separate write of the current buffer to a file is promised. Nevertheless, it does what question asked for.

          – mcepl
          Nov 17 '17 at 9:45














          0














          Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.






          share|improve this answer























          • This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

            – Patrick Sanan
            Jan 9 at 19:04











          • I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

            – kemotep
            Jan 9 at 19:43















          0














          Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.






          share|improve this answer























          • This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

            – Patrick Sanan
            Jan 9 at 19:04











          • I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

            – kemotep
            Jan 9 at 19:43













          0












          0








          0







          Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.






          share|improve this answer













          Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 9 at 17:26









          Patrick SananPatrick Sanan

          1033




          1033












          • This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

            – Patrick Sanan
            Jan 9 at 19:04











          • I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

            – kemotep
            Jan 9 at 19:43

















          • This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

            – Patrick Sanan
            Jan 9 at 19:04











          • I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

            – kemotep
            Jan 9 at 19:43
















          This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

          – Patrick Sanan
          Jan 9 at 19:04





          This answer isn't link-only. I didn't include the specifics of any particular plugin, because (as you say) particular plugins might become outdated.

          – Patrick Sanan
          Jan 9 at 19:04













          I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

          – kemotep
          Jan 9 at 19:43





          I stand corrected. However I would say in the future you should try to include relevant steps to implement the solution you are presenting. Thank you!

          – kemotep
          Jan 9 at 19:43

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f145289%2fhow-can-i-count-the-number-of-words-in-a-file-whilst-editing-the-file-in-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

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay