Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you do any kind of programming or system administration, learning vi or vim is definitely worth your time. The fact that it has a command mode allows you to move around and edit files tremendously faster than any other editor. I use it extensively on both Linux and Windows.
Many people like to dismiss vi because it's foreign to them and human nature tends to make us stay with what we are comfortable with. Therefore people point to the fact that it's old, it's been around forever and therefore, must be useless, but this is just human nature fighting against learning something new. If you decide you want to master linux, spend some time learning vi.
Many people like to dismiss vi because it's foreign to them and human nature tends to make us stay with what we are comfortable with. Therefore people point to the fact that it's old, it's been around forever and therefore, must be useless, but this is just human nature fighting against learning something new. If you decide you want to master linux, spend some time learning vi.
Since I was the only one who said that vi is old and dated, I suppose this is directly or indirectly meant to my comment.
I am very familiar with vi. I've done programming with to some extend and I still use it if I have to do some quick edit AND I happen to have a command line window open, otherwise I don't even bother.
So in my case, is not my "nature" fighting against learning something new. What it feels like for me when using vi (and even the command line sometimes) is that I am fighting against evolution itself, with so many, better, faster, easier to use and far more efficient editors than vi.
Than again, what is dated for me, maybe is not dated for some... for me using vi brings me back memories of granpa listening to the news and music in his huge mono radio. It is a sweet memory indeed, but I ratter browse the web from my cellphone for the news and listen to my music with an Ipod touch...
vi is easier to use and faster than gedit and even than ultraedit. It has a lot more useful functionalities.
As an advanced editor, it has a learning curve, though. For graphical vi, there is gvim.
Let's take an example:
You want to delete 5 paragraphs. in vi, you type :d5}, whereas in gedit, you have to select and visualise. It can take ages in gedit to do some tasks that vi can doo in half a second easily.
If you know vi, you can be efficient in editing text.
What you have to ask yourself is: do you have to be efficient when editing text? If you're not a programmer or don't have to edit many text files efficiently and don't need to be productive, then gedit may be enough. If you do edit text files often, or even all day, like I do as a programmer, then vi or emacs is a must.
Since the OP asked why would one would want to learn vim, I can think of two reasons. First, a rescue disk will have vim-minimal on it. So if you ever have a cause to use a rescue disk it would be a good thing to know how to use vim. Secondly, if you need to edit /etc/sudoers, /etc/passwd or /etc/group, you need to use visudo, vipw or vigr respectively. So at least knowing how to get into & out of edit mode "i" key & escape; and how to save the file and quit: ":wq" are good things to know.
Using gvim on occasions when you are running X is a good way to learn what the commands are.
Since the OP asked why would one would want to learn vim, I can think of two reasons. First, a rescue disk will have vim-minimal on it. So if you ever have a cause to use a rescue disk it would be a good thing to know how to use vim. Secondly, if you need to edit /etc/sudoers, /etc/passwd or /etc/group, you need to use visudo, vipw or vigr respectively. So at least knowing how to get into & out of edit mode "i" key & escape; and how to save the file and quit: ":wq" are good things to know.
Using gvim on occasions when you are running X is a good way to learn what the commands are.
Because you almost can always count on its being there
vi/vim is everywhere. Memorize a few commands, and you can do a lot. Of course, vim is not going to measure up to someone's favorite IDE or text editor -- mine being Epsilon -- but vim's minimalism comes in handy, especially when I'm not in a GUI environment and working as root.
Edit:
---------------------------------------------------------
On Ubuntu installs, I found out that vim-tiny is best replaced with the full-featured vim. My reason was handling of arrow keys while using insert mode.
Last edited by cmnorton; 05-16-2008 at 06:13 AM.
Reason: Add technical fact.
Since I was the only one who said that vi is old and dated, I suppose this is directly or indirectly meant to my comment
.....
better, faster, easier to use and far more efficient editors than vi.
...
First of all, this comment was not directed at you specifically, I teach Linux and hear similar types of comments all the time, and vi is definitely not the easiest editor to learn, however, it is extremely efficient. The key to working efficiently in vi is to stay in command mode, and this is what is foreign to new users of vi. Using the search [/], change [c] or substitute [s], find next [n] or repeat [.] commands, you edit files much more efficiently than any other editor. It does take some getting used to. Most of my students just learning vi don't like it, but when they take the uplevel classes, and see how quickly I can move around and edit a file, the realize its true power.
Last edited by rlhartmann; 05-17-2008 at 08:33 AM.
This will not work if X is not runninig, such as if
your logged in remotely from a windows machine, which
is how many unix/linux systems are administered, but
you could assign EDITOR to a text based editor,
vi/vim is everywhere. Memorize a few commands, and you can do a lot. Of course, vim is not going to measure up to someone's favorite IDE or text editor -- mine being Epsilon -- but vim's minimalism comes in handy, especially when I'm not in a GUI environment and working as root.
Actually, it's my favorite.
I've tryed emacs but it isn't as straight-forward as vi to me.
One point that I don't think has been mentioned is that the old editors are less likely to throw a hissy fit than the fancier ones. Try getting Gedit to open a 4MB file: when I had to do that, it just refused with the claim it couldn't recognise the encoding: plain ascii! I had to muddle through with *Nano* because I hadn't installed vi. It will never be my favourite program, but I've made sure I had vi available ever since.
Ubuntu 8.04 is my distro. I use the terminal to do various routines. I have used gedit to make some simple scripts. I am not a programmer.
Am reading Sobell's book on Ubuntu and reading about vim. Looks complicated.
Why should I use vim? Why not just gedit?
Thanks
The reasons of learning a command based editor are:
1) In case of ssh you don't have GUI
2) If you become a system administrator you will rarely use GUI
3) If something goes wrong with the GUI and you're unable to start an X manager you have to use nano, vim, emacs(i'm not sure about this one) to fix the problem
4) Several other reasons which I can't think of them right now.
But I would prefer to use nano instead of vim as it's much easier and simpler but vim offer some syntax highlights etc...
Thanks to all. I'm having a blast with vim. Mostly using it as a text file now, like notepad, but learning the commands. An excellent sourcebook for vim is located on vim.org in pdf format.
vi is fine for emergencies. I find it just to be a simple extension of ed which would have been regarded as fancy for its time. Salutations to its small memory footprint and ubiquitousness, but I think as a full fledged editor for a production environment, emacs is the best, largely because if you are quick at touch typing it wont take long to execute Meta-x and type in some obscure command which most probably has a very descriptive name.
I personally dislike the default modal nature of vi/vim. I had rather use Meta-x to change modes which I rarely have to do.
And ofcourse I dont think it is worth the effort learning to use vim for programming when so many intuitive IDEs are available, and IFF you are already familiar with one of them.
Emacs anyday for me. But I do agree that vi basics are essential knowledge for every person who has oppurtunity to login as root.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.