LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-16-2008, 12:37 PM   #1
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Rep: Reputation: 16
Smile 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.
 
Old 07-16-2008, 12:59 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
Enter the vi command mode, Press Esc then :
Save your file :w filename
then do !wc -w filename
Code:
:w testfile
:!wc -w testfile
word count output here
 
Old 07-16-2008, 01:00 PM   #3
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
In vim it's "g ctrl-g".
 
Old 07-16-2008, 01:59 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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 ]

Last edited by Mr. C.; 07-16-2008 at 02:11 PM.
 
Old 07-16-2008, 04:28 PM   #5
Chairman
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Rep: Reputation: 0
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
 
Old 07-16-2008, 04:38 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Excellent!

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!
 
Old 07-16-2008, 10:09 PM   #7
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Su-Shee View Post
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.
 
  


Reply

Tags
counting, editor, vi



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ "counting words in a string" Rico16135 Programming 11 05-06-2009 12:30 PM
counting words in file and sorting them according to their frequency mystical dervish Programming 4 05-10-2007 08:58 AM
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 07:48 PM
And counting... MasterC General 18 09-24-2003 05:07 AM
counting dummyagain Programming 3 09-24-2003 02:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration