LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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, 01: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, 01:59 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: Caldera, CTOS, Debian, FreeBSD, Mac OS X, Mandrake, Minix, OpenBSD, Slackware, SuSE
Posts: 1,757

Rep: Reputation: 79
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, 02:00 PM   #3
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

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

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

Rep: Reputation: 59
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, 11: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:30 PM
counting words in file and sorting them according to their frequency mystical dervish Programming 4 05-10-2007 09:58 AM
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 08:48 PM
And counting... MasterC General 18 09-24-2003 06:07 AM
counting dummyagain Programming 3 09-24-2003 03:28 AM


All times are GMT -5. The time now is 08:47 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration