LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   length of the word in vi editor (https://www.linuxquestions.org/questions/linux-newbie-8/length-of-the-word-in-vi-editor-662294/)

dina3e 08-12-2008 04:04 PM

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.

Mr. C. 08-12-2008 04:48 PM

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?

dina3e 08-19-2008 10:16 PM

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.

Mr. C. 08-19-2008 11:53 PM

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


Mr. C. 08-21-2008 09:55 PM

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.

dina3e 08-23-2008 09:18 AM

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 .


All times are GMT -5. The time now is 05:00 AM.