Recently i try to learn something about the unix. when i try to edit something using the vi command, it is very difficult for me since i have to switch the edit mode and control mode time by time. It is very inconvenient. Is it that i miss something or it is originally like that? Is there anyway to improve that? Thank you :)
migrated from stackoverflow.com Mar 24 '10 at 1:11
|
That's the way A good solution, when you're beginning using it, is to print a cheat-sheet of keyword shortcuts, and hand it on the wall next to your desk ;-)
But, considering |
|||
|
Easy OptionAs a short-term measure, you can run Vim in "easy mode" with:
This will start vim in insert-mode, so that you generally just type text straight in, and use the cursor keys to move around, like in most other editors. But I urge you to take the time to learn to use Vim (and Vi) properly, because once you get the hang of it (and that could take a few weeks) you'll find you can make quite complex edits much more quickly in Vim than in other editors. LearningIf it's a properly installed Vim, you can run the vimtutor command from the shell. This will guide you through basic movement, quitting, and simple editing. There are many "cheat sheets" for Vi and Vim: This one may help you visualize all the keyboard commands. Once you're a bit more confident in Vim,
will show you a more in-depth guide to using Vim as a first-timer, but that guide fails as a tutorial by not explaining how to move down the page until about six pages in. |
||||
|
|
|
Vi (and Vim) is a mode based editor by default. This is something a lot of users value, me included. If you however want a modeless editor, you might want to take a look at Emacs instead. It is also a very capable text editor (among other things, thanks to it being extendable by using Emacs Lisp). Nano might be an alternative as well, it is a lot more simple than Vi(m) and Emacs but it does what it's supposed to do (edit text). |
|||
|
|
|
No, you didn't miss anything, that's just how vi works. Once you get used to it, there's no hassle at all, and you prefer having the different modes. Notably, that you can use so many more keys to do things, such as hitting If you don't like it, give emacs or nano a try. Nano's supposed to be quite easy to learn & use. |
|||
|
|
|
One way to deal with the modal behavior of vim is to be in command mode by default. Only when you insert some text, you switch into input mode, but get right out of it as soon as you're done: you type a sentence and hit ESC right away. That way, you don't have to think so much about which mode you're in: you're in command mode unless you're typing input. Once you get more proficient with the editor and get to use its powerful editing commands, inserting text will become just another command to you like many other commands, and they're all initiated from command mode. |
|||
|
|
|
Do the official tutorial that is included with vim, it will take under an hour for a beginner and will give you a very good insight of what vim is capable of doing |
|||
|
|
|
Do you mean that it's cumbersome switching between insert mode and command mode using i and esc all the time? I'm afraid that's just the way vim works... |
|||
|
|
|
It is supposed to be that way. It's actually very powerful when you get used to it. My advice would be (1) to get a good cheat sheet and paste it up next to your workstation and (2) use nothing but vim for editing for a while until your fingers learn how to use it. Cheat sheet (available in several languages). |
|||
|
|
|
Why not just try using pico? It's a simple, fairly beginner-friendly text editor that comes with most Linux distributions (not sure about other unices). Type "pico" at the shell to launch it. |
|||
|
|
<Esc>ddand wondered a while, why in my line two literalds showed up... – Boldewyn Mar 29 '10 at 14:50