Cool Solutions

Quick Reference Tool for VI

rtburker

By:

September 17, 2014 10:00 am

Reads:4,465

Comments:1

Score:Unrated

Print/PDF

Download vic-1.0-1.noarch.rpm

Overview:
A tool to learn vi/vim or to be used as a quick reference tool – vic short for vi commands.

Symptom:
New to linux?  Just made the switch from NetWare to OES and would like to quickly edit files from a putty session?  vi/vim is a great text editor that has been around for years.  Once you understand a few commands getting around in vi/vim is easy to do, but you may not always remember some of the complex commands or a command you use all the time slips your mind.  You could open a browser and search for the command or use vic (VI Commands) from a terminal session.

Details:
VI Commands displays a quick list of options, from editing, to searching and replacing, to deleting text.

Starting vic displays an organized list of options

vic Main Menu

Start with option 1
Need to know how to begin editing in vi, the Input text will show you how, press i to insert before the marker or a to insert after the marker.  When you are finished looking at the options press enter to return to the main menu.

Common questions I get for editing a file with vi is how do I delete a row or delete the next 5 rows, or delete the next 5 words?  Press 4

vi delete

As you can see, x will delete the character under the marker.
5dd will delete 5 rows – starting from the marker down.
5dw will delete the next 5 words starting from the marker.

Searching and replacing can be easy to do.  Select option 7 – Search and replace text
The basic syntax for a search and replace is :s/old/new/.  This searches for old and replaces with new only on the current row.
Expand that to one of my favorites, search and replace the entire file, but ask for confirmation before applying the change.
:%s/old/new/gc
The g is global and the c is confirmation.  Add an i to ignore the case.

Once you get the hang of it, editing with vi gets easier and easier.  If you are familiar with regular expressions then many of the commands will look familiar to you.

For a time saver, give up the gui and start learning text editor like vi.  With vic, learning vi will be easy.  Refreshing your memory is a few key strokes away.  And the best part, you didn’t need to open a browser to learn the command.

Install:
Download vic-1.0-1.noarch.rpm
Install the rpm:
rpm -ivh vic-1.0-1.noarch.rpm

Usage:
Simple type vic to start learning vi.

If you receive the following message when starting vic “-bash: /root/bin/vic: No such file or directory”
Log in as the user again or use su.

vic has been tested on OES11SP1 and OES11SP2

Good luck!

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...


Categories: Cool Tools, Open Enterprise Server, Open Workgroup Suite, Technical

Disclaimer: This content is not supported by Micro Focus. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

1 Comment

  1. By:lsk040365

    This says noarch. I have tried to utilize this tool on 32-bit and error saying 64-bit only!

    What’s the deal?

Comment

RSS