How can I count the number of words in a file whilst editing the file in vim
Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
add a comment |
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
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
vim vi
asked Jul 18 '14 at 13:02
Michael DurrantMichael Durrant
15.9k44117183
15.9k44117183
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
.
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
add a comment |
Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
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
add a comment |
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
.
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
add a comment |
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
.
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
.
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
add a comment |
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
add a comment |
Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.
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
add a comment |
Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.
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
add a comment |
Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.
Plugins such as vim-airline can provide word counts for a file (and selections) as part of a status bar.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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