Printable Version of Topic

Click here to view this topic in its original format

914World.com _ 914World Garage _ OT: vim commands....

Posted by: bd1308 Aug 16 2005, 09:58 PM

I googled it and came up with information, but none of it could prove to be useful.

if i write something long, like a story or something and I want to edit a word in the middle, is there any way to skip line by line through the wrapped "line" in vim? or do I just have to use the right arrow key for ten days to go through each letter until i get the right one?

Posted by: Dr. Roger Aug 16 2005, 11:03 PM

In command mode....

:1, $s/word/anotherword/g will replace word with anotherword throughout the file.

Posted by: jkeyzer Aug 17 2005, 12:07 AM

hit enter every once in a while instead of entering huge wrapped lines, vim wasn't intended to be a word processor (in that sense)

Posted by: bd1308 Aug 17 2005, 05:12 AM

thanks guys. It's a shame though, because vim WAS meant to be way more than just a small editor for files.

mutt uses it.

Posted by: Gint Aug 17 2005, 05:38 AM

Look at the man page and other reference material for vi. vim uses similar commands.

Use "/" and then enter your search term or string. Then use "n" to go to the next of your search terms throughout the file. Then you can use standard vi like replace commands.

Roger came very cose. ":1" will take you to line 1, a different number will take you to that line. "Cntrl-g" will show you what line your actually on of how many lines in the file BTW. Use ":" to enter command mode if not already there. Then, %s/wordtoreplace/newword vim doesn't seem to require the "g" and the end to make the change global as vi does. So if you only want to change one word, you'll have to use the first method I listed (or one of many other's) or otherwise figure that out on your own.

Jeff's advice is good also. I always use manual line breaks with vi in a long file. It's only a text editor. It wasn't intended for desktop publishing.

Buy a book! Find a good tech forum. You can usually search and find answers to these types f questions on a good firum for the subject matter.

Posted by: bd1308 Aug 17 2005, 05:50 AM

thanks guys.


smile.gif

Posted by: jkeyzer Aug 17 2005, 10:07 AM

vim also has very, very extensive online help.

i used to use it every day a few years ago, now I stumble around in it like everyone else, but at least I am not terrified every time some unix app pops me into vi like i used to be.

biggrin.gif

PS: If you are used to Word, you are expecting that text will be automatically formatted to fit the page when you keep typing (without making your own line breaks). vim takes a simpler approach and lets you define the line breaks. I am guessing this is because in some programming languages line breaks define instructions and you wouldn't want the text editor to decide on the line structure for you.

vim is extremely powerful and hands down my favorite editor for coding, it is very fast and very coder-friendly. To tell you the truth, you can probably enable a feature to give it Word style line wraps/autoformatting. The preferences options are a mile long. Some versions also have a syntax highlighting feature for various programming languages, which is VERY cool. Check it out.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)