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
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]
Peon
I don''t like VI either. I used emacs from the very start under linux.
Well, R2D22U2..
Advertisement
quote: Original post by Peon
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..

*tries really hard to keep from tossing insults* You should not care what is l33t. I don''t care if you think you were just joking. You shouldn''t care. Do what works.

anyway,
emacs is another commandline alternative. anjuta is the most promising gui one.

quote: 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.
Yo, stop right there. You just need to know a little bit about vi. It was written a long time ago, and so vi itself has no frills. There''s no reason to use old-school vi or vi-compatible vim anymore except to be able to use it on different systems. Vim is much better. So get some sensible defaults. There are a bunch of indenting related options: smartindent, autoindent, shiftwidth, tabstop, softtabstop, expandtab. Look them up (:help topic). Smartindent is probably what you''re looking for. You may need to disable vi-compatible mode (:set nocompatible)

Syntax highlighting uses the extension (.c, .cc, .cpp, etc) to determine which syntax highlighting pattern to use. Vim has everything you''ve ever heard of and more, so you need to specify which one. On my system, at least, syntax highlighting is available from the start if you try to edit a file that doesn''t exist with a recognized extension (such an action creates the file when you write it to disk). If it''s not there, try :syntax on.

It sounds like you just need a more suitable .vimrc file.

Just like you can get faster with the command line than a GUI, you can get blindingly fast with vim commands, but there are a lot of them, and you have to know quite a few before you''re fast enough that using another editor gets tedious.

quote: 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..
Many people use emacs for everything. Many other people use vi for some files (typically small ones) and emacs for large ones.
---New infokeeps brain running;must gas up!
I use vim everyday at work to write in Perl/HTML. I love it. It is SOO much faster than using a GUI tool. Not having to switch from mouse to keyboard is a big plus when you are only concerned about speed.

I have vim for windows installed on my home machines. I don''t use it to write C++ code, but it definitely replaces Notepad as my default editor.

Once you get used to vim commands, nothing else is faster.
quote: Original post by Anonymous Poster
I use vim everyday at work to write in Perl/HTML. I love it. It is SOO much faster than using a GUI tool. Not having to switch from mouse to keyboard is a big plus when you are only concerned about speed.

I have vim for windows installed on my home machines. I don''t use it to write C++ code, but it definitely replaces Notepad as my default editor.

Once you get used to vim commands, nothing else is faster.


*Nods in strong agreement*

Vim rocks!



--------------------------------------
I''m not a freak, I''m just really shiny.
--------------------------------------I'm not a freak, I'm just really shiny.
Advertisement
vi != vim.

Though VERY often people use the two terms interchangably.

vi works but is a last ditch alternitive... vi IS really primitive.

vim on the other hand well ROCKS (in big font, multi colors and all that other pompus crap).

Fwiw, I''m one of the vim addicts. There are alot of us. There is a reason for it too.


Regardless of my personal preferances it is worth having at least basic knowledge of vi as it is found on just about every nix system...

That said, There is a multitude of editors out there, odds are you''ll find one you like.


Fwiw you might ask your instructor what he expects...


Oh and, imho, leet is a retarded notion best left in the past.

Luck
Anyone who thinks you are lame because of your choice in editor is probably not someone you should associate with.

Let your code do the talking.

As an experienced vi user (I actually do like writing code with vi, typically on an SGI Irix system), I can see the merit in learning it, as it is pretty much the only editor gaurenteed to exist on a Unix system (Solaris, HP-UX, Linux, Irix, AIX, etc). I''ve seen a ton of people practically crippled by jumping over to someone else''s environment in unix land (they can''t do anything).

My recommendation is to learn the basics of vi, as sometimes it may be the only thing available, but in general, stick to what you like. The VC++ editor is a fine choice (my editor of choice when coding on Windows). Heh, I did all of my college work in the Turbo C IDE way back when... (for Solaris boxes).
Well thanks for the opinions guys A few comments:

My question about the "l337ness" of a GUI editor was SOMEWHAT serious, but not completely. I was just thinking that if some people can just use a command line / vi, I should be able to do. Afterall, as others people pointed out, I will always have vi; I might not have a nice GUI program on the system. I feel like that when using vi right now, I am really impaired in my productivity (as a programmer) The editor shouldn''t matter so much, IMO.

I''m definetly going to continue learning vi, as that''s what my professor suggested. I''d like to give it a chance personally too, so it''s not like I''m completely giving it up. I still have doubts as to whether or not I could really become faster with vi than a GUI editor though. There are realy advantages that can be had, especially when skipping around code, best accomplished with a mouse (IMHO). I also recognize that I am still a newbie when it comes to vi, and Linux / Unix in general, so there may be commands that help in this regard. That''s another reason I don''t want give up yet.

It''s a great little program, I just can''t see myself writing anything much more complicated than "Hello World" in it. I guess I''ll have to see how it goes once the class goes on and I become more a accustomed to it.
Peon
I can''t believe you guys don''t like vi. That is my editor of choice! It comes in very handy when I don''t want to leave my dorm room, I can work on all my cis projects by telneting/ssh or some other method and get to work. I know I could open emacs, but I don''t like programs that can do everything. emacs is terrible across a network.

Brad
-brad

This topic is closed to new replies.

Advertisement