How can I count the number of words in a file whilst editing the file in vim2019 Community Moderator ElectionHow to store Vim tabstop settings in the file?How can I paste (overwriting) with vim?Vi vs vim, or, is there any reason why I would ever want to use vi?How can I create my own spelling file for vim?Any way to provide a separate vimrc file just for 1 sessionHow can I get vim to return to normal tab display?Vim: Count all occurrences (including multiple on the same line) of char or wordCan I jump to a jump by its number in vim?How can I stop vim from editing directories?How does the processor determine each instruction's opcode and operands: looking into binary file with VIM
Grepping string, but include all non-blank lines following each grep match
Echo with obfuscation
Sigmoid with a slope but no asymptotes?
Make a Bowl of Alphabet Soup
How to preserve electronics (computers, iPads and phones) for hundreds of years
How to make a list of partial sums using forEach
How to make money from a browser who sees 5 seconds into the future of any web page?
How many people need to be born every 8 years to sustain population?
How to leave product feedback on macOS?
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
How to reduce predictors the right way for a logistic regression model
Isometric embedding of a genus g surface
Can I cause damage to electrical appliances by unplugging them when they are turned on?
What is the smallest number n> 5 so that 5 ^ n ends with "3125"?
Personal or impersonal in a technical resume
Language involving irrational number is not a CFL
Has the laser at Magurele, Romania reached a tenth of the Sun's power?
Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?
Do I have to take mana from my deck or hand when tapping a dual land?
Did I make a mistake by ccing email to boss to others?
Anime with legendary swords made from talismans and a man who could change them with a shattered body
I'm just a whisper. Who am I?
Mimic lecturing on blackboard, facing audience
If the only attacker is removed from combat, is a creature still counted as having attacked this turn?
How can I count the number of words in a file whilst editing the file in vim
2019 Community Moderator ElectionHow to store Vim tabstop settings in the file?How can I paste (overwriting) with vim?Vi vs vim, or, is there any reason why I would ever want to use vi?How can I create my own spelling file for vim?Any way to provide a separate vimrc file just for 1 sessionHow can I get vim to return to normal tab display?Vim: Count all occurrences (including multiple on the same line) of char or wordCan I jump to a jump by its number in vim?How can I stop vim from editing directories?How does the processor determine each instruction's opcode and operands: looking into binary file with VIM
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
16.4k45121186
16.4k45121186
add a comment |
add a comment |
3 Answers
3
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 also try for :!wc %
in Vim, though it counts the size of the file on-disk, not what is in Vim's buffer. This may or may not be what you wanted.
New contributor
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).
– Jeff Schaller
16 hours ago
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 |
protected by Archemar 18 hours ago
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
3 Answers
3
active
oldest
votes
3 Answers
3
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.9k976120
35.9k976120
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 |
You can also try for :!wc %
in Vim, though it counts the size of the file on-disk, not what is in Vim's buffer. This may or may not be what you wanted.
New contributor
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).
– Jeff Schaller
16 hours ago
add a comment |
You can also try for :!wc %
in Vim, though it counts the size of the file on-disk, not what is in Vim's buffer. This may or may not be what you wanted.
New contributor
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).
– Jeff Schaller
16 hours ago
add a comment |
You can also try for :!wc %
in Vim, though it counts the size of the file on-disk, not what is in Vim's buffer. This may or may not be what you wanted.
New contributor
You can also try for :!wc %
in Vim, though it counts the size of the file on-disk, not what is in Vim's buffer. This may or may not be what you wanted.
New contributor
edited 13 hours ago
ilkkachu
61.9k10102178
61.9k10102178
New contributor
answered 20 hours ago
Pranav SuriPranav Suri
111
111
New contributor
New contributor
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).
– Jeff Schaller
16 hours ago
add a comment |
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).
– Jeff Schaller
16 hours ago
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
This counts what’s on disk (if anything), not what’s in the buffer — so if you have changed the contents of the buffer since the last save, or not saved at all, you’ll get the wrong count (or even an error if you’re creating a file).
– Stephen Kitt
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Contra Stephen, this is a correct solution to "How can I count the number of words in a file whilst editing the file in vim", while the accepted answer strictly-speaking isn't (although it's ambiguous what was meant or whether it matters).
– Michael Homer
18 hours ago
Funny that it's similar (minus the
-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).– Jeff Schaller
16 hours ago
Funny that it's similar (minus the
-w
flag to restrict the output to words only) to a delete answer from 2014 by D_Bye (who apparently self-deleted it).– Jeff Schaller
16 hours ago
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 |
protected by Archemar 18 hours ago
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?