LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


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

Rep: Reputation: 16
Cool length of the word in vi editor


i am looking for something that gives the length of the perticular word in the vi/vim editor, the word may be searched one or under the cursor.
 
Old 08-12-2008, 04:48 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Gives it ,as in allows you to compute it, or do you need a return value that you can use in some fashion?

For example, vim will show you column numbers, whereby you can computer the width.

You can also send a word to a shell command to calculate the word length.

Please clarify you needs and usage, or is this just a homework question?
 
Old 08-19-2008, 10:16 PM   #3
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
I am absolutely made about the vi editor , i am try to play with this editor and be master of this editor , so that i think this length of the word may greater flexible of the editor. just tell me how to implement all these things in a functions.
 
Old 08-19-2008, 11:53 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
I've been using vi for over 25 years... my fingers themselves just "think" vi. In all those years, I have never had the need to have vi tell me the length of a "word". Rather, I tell vi to do something to a word, and even define what words are.

In vi (not vim), determinging the length of a word would require using external commands, where a word could be used as input to wc -l.

In vim (which you think of as vi), there is an entire programming language. This is an area I'm not well experienced, and have had little need, so I can't help you here. This would be a good question for the vim.org mailing lists.

If you are serious about becoming a "master", spend some time learning how to perform shell escapes using editor content as input. Hint: try each of the following lines while editing some test file - see if you can tell what they are doing. Hit Enter after each command you try, and u to under

Code:
!!ls
!!date
!Gwc -c

Last edited by Mr. C.; 08-19-2008 at 11:56 PM.
 
Old 08-21-2008, 09:55 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Ok, dina3e, here's your answer. I discovered this while reading the vim documentation about a topic today.

Go to the beginning of a word, and type the following:

veg^G

That's the v key, followed by the e key, followed by g and the Control-G.

This goes to Visual mode, selects in visual mode to the end of the word, g Control-G gives status of the current cursor position. In visual mode, you'll get the number of characters on the status line, like this:
Code:
Selected 1 of 90 Lines; 1 of 384 Words; 3 of 2948 Bytes
I've highlighted the word length in red.

Last edited by Mr. C.; 08-21-2008 at 10:26 PM.
 
Old 08-23-2008, 09:18 AM   #6
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
Mr.C whatever you post is amazing about the vi editor "escape sequence" which really made things so easy .

g and CTRL-g gives the properties of the cursor but came to knew that it also works for the block special .

thank's for the innovative idea's .
 
  


Reply

Tags
length


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
[SOLVED] find a word in a file, and change a word beneath it ?? vikas027 Programming 10 02-14-2008 10:46 PM
The search term you specified (No) is under the minimum word length xpucto LQ Suggestions & Feedback 1 11-13-2007 06:37 AM
Word wrap in text editor (shell) Kitten78 Linux - Software 5 09-08-2006 12:28 AM
replace a word in vim editor fssengg Linux - Newbie 3 03-10-2005 09:39 AM
remove color after word search in vi editor dylan912 Linux - Newbie 1 12-10-2004 05:15 AM


All times are GMT -5. The time now is 03:14 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration