Vim

You can talk about anything here, not necessarily game-related. You may also advertise here.
Post Reply
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

is amazing.

As an editor, it has a high learning curve. There are zillions of commands, and it's said you won't be faster than an emacs user until you've learned 40-50 keybindings. I've learnt perhaps 30, and I don't use more than 10-20 routinely. So for simple text editing, I'm slower than with emacs.

As a generic text munger, however, it has a fairly low learning curve. For text transformations, you can beat an emacs or sed/awk user in a few days. Here's one thing of fun practical value. I wanted to know how many episodes there are in each series of Me and My Girl, a TV series. Possibilities? Look it up on IMDB, search around on Google, or... put it into Vim. So I pasted the Wikipedia series descriptions into vim, and within moments found a suitable command to execute:

code: Select all

:/*/;/^$/-1!wc
99@:
It was only after I executed the command that I realised how effortless and natural it was. With sed/awk, it might take me several minutes to write a suitable script. I've no idea how to accomplish it in emacs (or any other editor, really). With vim, effortless. (I used the time saved to write this post. :))

What the command line does: Filter the range from the next occurrence of * to the next blank line minus one through the wc command. Since that did what I wanted, repeat 99 times (there are only 6 series, so it only did it 6 times, of course).

What the first two paragraphs looked like before:

code: Select all

  1 Series 1 (31/8/84 - 5/10/84)
  2 
  3     * I Love You Samantha
  4     * Design for Loving
  5     * The Ideal Husband
  6     * The Home Help
  7     * Jobs for the Girls
  8     * A Clean Slate
  9     
 10 [edit] Series 2 (18/1/1985 - 1/3/1985)
 11     
 12     * Love and Kittens
 13     * Let's Talk Turkey 
 14     * Sticky Fingers
 15     * The Kids Are Alright 
 16     * Leaving On a Jet Plane
 17     * Swings and Roundabouts
 18     * You Take the High Road
And after:

code: Select all

  1 Series 1 (31/8/84 - 5/10/84)
  2 
  3   6  26 139
  4     
  5 [edit] Series 2 (18/1/1985 - 1/3/1985)
  6     
  7   7  32 182
Remember, this isn't even text editing, something vim is very good at, but with a higher learning curve. This is just programmatic text manipulation. Moreover, manipulation using only the most basic and easy features of vim. So if you are a heavy user of plaintext files (I certainly am, since I keep virtually everything in plaintext files), vim is fairly indispensable.
:wq
User avatar
bjornredtail
Warbands Admin
Posts: 821
Joined: Tue Apr 20, 2004 12:07 am
Contact:

Post by bjornredtail »

To spite my utter n00bishness, I still appreciate the awesomeness of VIM. It is similar to what would arise if I were to play the Davidov or Duport Stradivarius...

Not to be antisocial, of course.

EDIT: Any good reason for this to be in spam?
0===)=B=j=o=r=n==R=e=d=t=a=i=l==>
Warbands Admin

"Program testing can be used to show the presence of bugs, but never to show their absence!"-Edsger W. Dijkstra
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

I thought people might not be interested. But seeing as how it wasn't as antisocial as I thought it would be, I'll move it to GD.
:wq
User avatar
Kraken
MLR
Posts: 1522
Joined: Tue Apr 12, 2005 2:59 pm
Location: Tennessee USA hooah!
Contact:

Post by Kraken »

im not trying to be antisocial in the least bit but......what the f@$%& are you guys talking about to all of us.....well me mostly....computalk peeps out there.
all about FAVRE, come on...you know you want to click it

..."I'm sorry, but I really can't see anything redeeming in your philosophy other than that dinosaurs are cute."
~Beatles

The Kraken, which is found primarily in Scandinavian myth, was a huge sea creature. It was said to lie at the bottom of the sea for a long time and then it would rest at the surface....Like the Midgard serpent in the Norse myths, the Kraken was supposed to rise to the surface at the end of the world.
User avatar
bjornredtail
Warbands Admin
Posts: 821
Joined: Tue Apr 20, 2004 12:07 am
Contact:

Post by bjornredtail »

VIM is a text editor, similar in purpose to notepad... However VIM has literally thousands of features and capabilities to make coding and digging through vast text files. All of these features take some effort to learn, but the results are apparently well worth it. It is these capabilities and learning curve that we are referring to.
0===)=B=j=o=r=n==R=e=d=t=a=i=l==>
Warbands Admin

"Program testing can be used to show the presence of bugs, but never to show their absence!"-Edsger W. Dijkstra
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

Precisely.

Other text editors have been written that have very many features for editing text and organising projects and searching through code and whatnot. Editors with tens of thousands of features, all for manipulating simple text, not even any formatting or other features. And perhaps for simple text editing, some of these surpass VIM. Yet not another tool can touch the programmatic, elegant, and powerful philosophy of editing introduced by vi, now over 30 years ago. VIM has carefully and excellently carried on the vi tradition. At its best, text manipulation with VIM is more than efficient or fun, it's beautiful.*






* Naturally, to the extent that text manipulation can be considered beautiful at all, which does depend on your taste.
:wq
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

I found a simpler (better) way... through learning a new command, g. (Do for each matching line.)

So just one command

code: Select all

:g/Series//*/;/^$/-1!wc
As above, but with ":g/Series/" prepended. In words: for each line matching "Series", filter the range between the next star and the next blank line minus one through the "wc" program.
:wq
User avatar
Kraken
MLR
Posts: 1522
Joined: Tue Apr 12, 2005 2:59 pm
Location: Tennessee USA hooah!
Contact:

Post by Kraken »

i saw a protest sign that read </bush>
what would that mean?
all about FAVRE, come on...you know you want to click it

..."I'm sorry, but I really can't see anything redeeming in your philosophy other than that dinosaurs are cute."
~Beatles

The Kraken, which is found primarily in Scandinavian myth, was a huge sea creature. It was said to lie at the bottom of the sea for a long time and then it would rest at the surface....Like the Midgard serpent in the Norse myths, the Kraken was supposed to rise to the surface at the end of the world.
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

That isn't relevant in any way, shape, or form.
:wq
User avatar
Gen. Volkov
I'm blue, if I was green I would die.
Posts: 2342
Joined: Sat Dec 11, 2004 11:47 pm
Location: Boringtown, Indiana

Post by Gen. Volkov »

It means "slash bush" Kraken.
It is said that when Rincewind dies, the occult ability of the human race will go UP by a fraction. -Terry Pratchett
User avatar
Slasher
The FAF Forums SMEGHEAD!!! lol
Posts: 2635
Joined: Mon May 03, 2004 5:08 pm
Location: http://florida4us.com/
Contact:

Post by Slasher »

Gen. Volkov wrote: It means "slash bush" Kraken.
HOW DARE YOU! I AM NOT BUSH!!!
I do not have a signature, you must be imagining

http://florida4us.com/

Image
User avatar
Kraken
MLR
Posts: 1522
Joined: Tue Apr 12, 2005 2:59 pm
Location: Tennessee USA hooah!
Contact:

Post by Kraken »

Slasher wrote:
Gen. Volkov wrote: It means "slash bush" Kraken.
HOW DARE YOU! I AM NOT BUSH!!!
*laughs*

clever then
all about FAVRE, come on...you know you want to click it

..."I'm sorry, but I really can't see anything redeeming in your philosophy other than that dinosaurs are cute."
~Beatles

The Kraken, which is found primarily in Scandinavian myth, was a huge sea creature. It was said to lie at the bottom of the sea for a long time and then it would rest at the surface....Like the Midgard serpent in the Norse myths, the Kraken was supposed to rise to the surface at the end of the world.
User avatar
Nuclear Raunch
The Wanderer
Posts: 950
Joined: Tue May 24, 2005 4:30 am

Post by Nuclear Raunch »

</Enter word here> is usually used to close a tag, like a quote tag in many forums, or a bold tag, or whatever. In geek speak the beginning of Bush's presidency would be <Bush> and the end would be </Bush>
I know the voices in my head arn't real but they usually have some pretty good ideas.
User avatar
The Beatles
Fear me for I am root
Posts: 6285
Joined: Tue May 24, 2005 8:12 pm

Post by The Beatles »

That's about as geeky as myspace, though. True geeks might opt for
:%s/Bush//g

or even
:g/Bush/d (variation: grep -v Bush)

True zealots might even go for find / -name Bush -exec rm -rf {} \;

But that's for the really one-minded. ;)
:wq
Post Reply
  • Members connected in real time

    🔒 Close the panel of connected members