Advertisement

Write code in Vi == teh suck

Started by October 04, 2003 12:56 PM
48 comments, last by Peon 20 years, 10 months ago
I too don''t like to use vi unless I''m in a telnet session where I have no other choice.. even then I still like to paste my code first and then do only minor editing in it.

Windows GUI based editor, esp. the ones that have their source code available (like openPerl-IDE) really rock. Maybe its because the latter is totally KISS based while the former being text based and so overloaded with features, sometimes just scare the n00bs (everybody is a n00b once, right?) away. That''s why I kinda liked pico more when I started but then switched to vi only later.
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";
I''m going to throw you dogs a bone here. It''s a nice juicy big bone.

Awesome ViM page

RandomTask
Advertisement
Bah... vi is definately NOT the only editor you''re guarenteed to find on any UNIX sytestem:

ed

Ed is (probably) available on EVERY *nix system EVER (even before vi was written)! Ed is a REAL editor -- No error messages, no visual display, no prompt. (Actually I lied, there is one error message -- "?"). And at a mere 43K, it''s probably also the smallest editor, an order of magnitude smaller than vi, and two orders of magnitude smaller than emacs.

In all seriousness though, I usually usually use emacs for most editing, and either nano (not usually available, I don''t think, but is the default mini-editor on Debian GNU/Linux), and only use ed if I need to type in a small file, or making _really_ minor changes.
quote: Original post by Garfong
Bah... vi is definately NOT the only editor you're guarenteed to find on any UNIX sytestem:

ed
You said it, man!
quote: From http://www.gnu.org/fun/jokes/ed.msg.html
When I log into my Xenix system with my 110 baud teletype, both vi*and* Emacs are just too damn slow.  They print useless messages like,'C-h for help' and '"foo" File is read only'.  So I use the editorthat doesn't waste my VALUABLE time. Ed, man!  !man ed ED(1)               UNIX Programmer's Manual                ED(1) NAME     ed - text editor SYNOPSIS     ed [ - ] [ -x ] [ name ]DESCRIPTION     Ed is the standard text editor.--- Computer Scientists love ed, not just because it comes firstalphabetically, but because it's the standard.  Everyone else loves edbecause it's ED! "Ed is the standard text editor." And ed doesn't waste space on my Timex Sinclair.  Just look: -rwxr-xr-x  1 root          24 Oct 29  1929 /bin/ed-rwxr-xr-t  4 root     1310720 Jan  1  1970 /usr/ucb/vi-rwxr-xr-x  1 root  5.89824e37 Oct 22  1990 /usr/bin/emacs Of course, on the system *I* administrate, vi is symlinked to ed.Emacs has been replaced by a shell script which 1) Generates a syslogmessage at level LOG_EMERG; 2) reduces the user's disk quota by 100K;and 3) RUNS ED!!!!!! "Ed is the standard text editor." Let's look at a typical novice's session with the mighty ed: golem$ ed ?help???quit?exit?bye?hello? ?eat flaming death?^C?^C?^D? ---Note the consistent user interface and error reportage.  Ed isgenerous enough to flag errors, yet prudent enough not to overwhelmthe novice with verbosity. "Ed is the standard text editor." Ed, the greatest WYGIWYG editor of all. ED IS THE TRUE PATH TO NIRVANA!  ED HAS BEEN THE CHOICE OF EDUCATEDAND IGNORANT ALIKE FOR CENTURIES!  ED WILL NOT CORRUPT YOUR PRECIOUSBODILY FLUIDS!!  ED IS THE STANDARD TEXT EDITOR!  ED MAKES THE SUNSHINE AND THE BIRDS SING AND THE GRASS GREEN!! When I use an editor, I don't want eight extra KILOBYTES of worthlesshelp screens and cursor positioning code!  I just want an EDitor!!Not a "viitor".  Not a "emacsitor".  Those aren't even WORDS!!!! ED!ED! ED IS THE STANDARD!!! TEXT EDITOR. When IBM, in its ever-present omnipotence, needed to base their"edlin" on a UNIX standard, did they mimic vi?  No.  Emacs?  Surelyyou jest.  They chose the most karmic editor of all.  The standard. Ed is for those who can *remember* what they are working on.  If youare an idiot, you should use Emacs.  If you are an Emacs, you shouldnot be vi.  If you use ED, you are on THE PATH TO REDEMPTION.  THESO-CALLED "VISUAL" EDITORS HAVE BEEN PLACED HERE BY ED TO TEMPT THEFAITHLESS.  DO NOT GIVE IN!!!  THE MIGHTY ED HAS SPOKEN!!! ? 


[edited by - CWizard on October 9, 2003 2:27:22 PM]
quote: Original post by Peon
My question about the "l337ness" of a GUI editor was SOMEWHAT serious, but not completely.


To be l337, you would not use a text editor, much less a gui . You would still write in hex, when you weren''t keying in op codes from memory.

I tried to use KDevelop, Anjuta, gedit, Kylix, and a bunch of other crap. If I need to edit a file on the linux box now, I just use vi if I''m at a conole, and vim if I have X running.

i for insert, esc to stop inserting, :w to save, :q to quit, have at it.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Vi takes a while to learn, but it is definitely a superior editor to the one that comes with any of the MS dev stuff. Remember, we''re comparing editors with editors, not editors with IDEs.

If you saw someone who was truly proficient at using vi, you''d understand its power. The cursor flies all over the screen, going to the exact place where the user desires in a few key strokes. Very efficient.

You will find that a lot of things in unix are made to be very efficient and to make you be very efficient, if you are willing to learn a little bit.

Besides, real unix users do all of their editing using sed

Re: ed

"Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither a speedometer, nor a gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant "?" lights up in the center of the dashboard. "The experienced driver," says Thompson, "will usually know what''s wrong."
Advertisement
quote: Original post by Peon
God, I don''t know how anyone can write code in Vi. My beginning C class (LOL!) had a brief lesson on Unix commands and I must say, I absolutely hate using vi to write my code. I''m used to using MS VC++.NET, though I''m sure that there are graphical Linux alternatives as well. I realized there is so much I take for granted.

A return key after a brace in .NET will automatically indent for you. Perhaps the most valuable thing you lose with vi however is the ability to have your code color coded (until you reload it, apparently) And I REALLY miss my mouse. The error messages are not as "user friendly" either.

I guess the instructor expects us to write the code in Vi, but for my first program I wrote it in .NET and pasted it over. It''s just so hard to use compared to .NET. I''m really going to try and use vi effectively, but I can''t help but think that it is REALLY primitive.

Is using a graphical alternative (like .NET or similar editors) "l337" enough? I''m really interested in seeing what Linux power users use to write code. Tell me it''s not vi..

However, on a more positive note, I DO like using Linux, and the command line. I''m still better with Windows, but I''d be willing to bet I can be faster using Linux if I practice enough.


[edited by - Peon on October 4, 2003 1:58:40 PM]



To be quite frank, alot of Linux hackers use either "vi" or "emacs" both of which I have been a user at one point or the other. I started out using emacs because of an old old GTK programming book that got me all set to code using emacs. I had it configured the way I wanted it and all. A couple of years ago, I decided to give "vi" another chance and haven''t changed as of yet. As for color coding the command ":syn on" (without the quotes) in command mode, will Hilight your code. As for autoindent, I don''t remember the command by heart, since it''s set in my script, but that too can be achieve.

If you want to use GUI Dev environments, either use KDevelop ( KDE ) or Anjuta( GNOME, this would be my choice if I had to code using a GUI). Even though I wrote their respective Window Managers net to them, in brackets, they can be interchanged without any problems just as long as you have all the libs needed. If you''d like to get either one, google it( I was too lazy to write the URL, even though I know it by heart ).

[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com][ Administrator & WebMaster GuLSE]
[Cyberdrek | ]
Another vim advocate here

When I first started programming in college the professor recommended, actually I think we had to go through a vi tutorial or something. Anyway I tried using it and had a lot of problems. After that class was over I didnt have to use it until the next year. Now I use it for all of my coding/text editing, unless I have something that needs specific formatting then I use Word. I have gvim for windows.

I think yy is the best command ever, no need to highlight text before copying, just yy move to the line you want to copy it to and p. Easy, simple, dont need to move my hands to the mouse.

But as others have said, find what works for you. I would suggest learning to use at least one linux editor since vc/gcc dont always compile with the same code. Myabe this is different with .NET. I use to write my code in MSVC++ and then ftp it to the school linux machine only to find gcc didnt like my syntax even though MSVC++ compiled with no errors.

Clippy:"OMG, A NUMBAR! Let me format it for you"
Unsuspecting Student: "Ahhhhh! Damn you paperclip you ruined my paper. A thousand deaths upon you!"

"Game Programming: Without programming you''ve just got game"
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson
I think the true power of vi (apart from being touch typing friendly) is how tasks are broken up into a what-you-want-to-modify and then how-you-want-to-modify-it.

For instance,
You can combine

aw = a word (i.e. word cursor is on)

with

d = delete

or

y = yank (aka copy.. wierd name, at a guess because because c=change)

so, `daw` will delete the current word and `yaw` will yank the current word.

Note this is simplified as you can add (optional) counts and registers, see `:h count` and `:h registers` respectivly.

I find this methodology easy to both understand and remember, as well as being both powerful and efficient.

Oh and more to the point of the post: vim.sf.net!

Each to their own ofcourse
*edit: you would think I'd recall how to post a link here *

[edited by - FeralofFireTop on October 14, 2003 3:39:50 AM]
At work I ssh into a linux box and write code, vim's the best editor available. I've always been indifferent to vim, no real opinion. But slowly but surely I'm starting to really like it.

vi just friggin sucks . I'm currently taking an OS class where we are using Minix in a Bochs virtual computer. vi is the one and only editor we can use in there. I hate it so much I'm going to compile in network support and go out and download vim (assuming bochs will let me, as far as I know no tool exists to write into/out of bochs disk images).

[edited by - tortoise on October 15, 2003 3:32:23 AM]

This topic is closed to new replies.

Advertisement