Cambridge IT Courses Blog: 5 commands you need to know to use VI
VI: THE command line editor
The VI editor has powerful features to aid programmers and as it runs on the command line it makes it particularly useful if you need to edit files on a server. However, many beginning users avoid using VI because of the steep learning curve. That's why we'll show you 5 commands you need to know to use VI:
You open a file with:
If the file doesnt exist, it will be created!
VI ModesIn Vi you have to switch between three basic modes:
The Command mode is the normal mode you are in when you enter the VI.
5 useful VI commands:
Saving files:Go into Command mode (press "Esc" if in doubt), then type:
:wFollowed by "Enter".
To save and exit use:
VI Viewing options:With
:vsplit and :hsplityou can split the VI horizontal or vertical. With that function you can easily compare code or work on you HTML and CSS sheet at the same time
For line numbers you can use
:setnuto show them, or
:setnonuto hide them!
Copy and Delete:When you want to paste or copy code you can use
:y for 1 line or :y3 for 3lines
When you want to delete one or more lines use:
:d or :d3 for 3lines
Once you've mastered the basics get yourself a good 'cheat sheet' such as: http://bullium.com/support/vim.html And when you've used VI for a while writing code with shortcut commands will be much more efficient than a GUI/ mouse based text editor!
Posted by Deniz Gruenberger at 22:15 2011-05-21 | Trackbacks (0) | Comments (0)
Cambridge IT Courses Blog
Articles, tips and tricks discussing technical issues related to our courses