-   Linux - Software (
-   -   counting the words in vi editor. (

dina3e 07-16-2008 01:37 PM

counting the words in vi editor.
how to count the number of words in vi editor?? i am finding the words using / but these seems to be highlighted from there i count the words but it's very difficult to count for the big files. i am looking for the command in the vi editor not in the shell prompt using any sed,awk,or tr commands.

bsdunix 07-16-2008 01:59 PM

Enter the vi command mode, Press Esc then :
Save your file :w filename
then do !wc -w filename

:w testfile
:!wc -w testfile
word count output here

Su-Shee 07-16-2008 02:00 PM

In vim it's "g ctrl-g".

Mr. C. 07-16-2008 02:59 PM

From within vim, type:

:help statusline

Towards the end of the statusline help section, there are examples of how to enable the status line so that it always shows number of characters, modified, etc.

[ edit: I should clarify, this comment ammends Su-Shee's comment re: Ctrl-G. This is a way to see the status line at all times, but has no word count functionality. While such could be implemented, it would be very expensive to perform ]

Chairman 07-16-2008 05:28 PM

vim word count
So many people have been working to expand Vim that I didn't try to read the documentation to find the count words plugin.

I created a Vim file and saved it.

Opened gedit -> edit menu -> preferences -> plugins -> enable Document Statistics -> close.

Open the file you want with gedit -> tools menu -> Document Statistics

Mr. C. 07-16-2008 05:38 PM


Now that you mention this Chairman, I do recall seeing that plug-in once, and I thought, why would I ever use that, and forgot all about it. Good call!

dina3e 07-16-2008 11:09 PM


Originally Posted by Su-Shee (Post 3216660)
In vim it's "g ctrl-g".

as these shows the status line of the cursor mean no.of words,lines etc..
similarly i need command that search the words and count that word in the preticular file.

All times are GMT -5. The time now is 11:41 PM.