Skip to main content

VI shortcuts Fasttrack

Let me summarize here with few vi commands for Fast reference:

Inserting text

esc + i insert text informant of the cursor
esc + a append text after the existing text
esc + O opens new line above the current line
esc + o opens new line under current line (insert mode)

Deleting text

esc + x deletes one character
esc + 5x deletes five charters
esc + dw deletes a word
esc + 5dw deletes five words
esc + dd deletes the whole line
esc + D deletes the line from cursor and forward
esc + d) deletes the sentence from cursor and forward
esc + d( deletes the sentence from cursor and backwards
esc + u undelete

Note: esc + d) or d( removes the sentence from cursor and forward/backwards
until it reaches a dot "."

Moving around in VI:

Make sure you are in command mode and the following letters will do:

j moves you down
k moves you up
h moves you left
l moves you right

Finding Text

Hit esc then type in a / you then go to the bottom of the screen
where you will see your / type in the text to look for.
ie. /Linux
that will find the word `Linux` in the open file.

Replacing Text

Hit esc and do: :start,stop,s/s_text/r_text/g

: indicates that this is an ex command
start is the starting line number
stop is the stopping point
s is the substitute command
s_text is the search string (the text you are looking for )
r_text is the text you are replacing with
g is global

Example:

Esc + :5,8,s/l/ll/g

This would replace all "l"'s with "ll" on lines 5 to 8.

Note to Replacing Text:
Line numbers can also be:
. current line
$ last line

Basic save & quit commands

Hit Esc and do a : where after you can type the commands.

w write (save)
q quit
! force

ie. :q! or :wq

To create control characters do:

Ctrl+V Ctrl+

Example:

Ctrl+V Ctrl+A

That will create a ^A character.

(These last 3 commands are very alike ed commands)

Another useful thing in VI is split-screen mode, so you can edit 2 files
at once, this is:

:split

Just press Esc and type ":split".

Comments

Popular posts from this blog

access logs to PDT

zgrep "text" /var/log/nginx/access.log | awk '{print $6}' | sed -e 's/\"/\ /g' | awk -F'[:/]' '{   # Build a new date string that GNU date can understand   timestamp = $1 " " $2 " " $3 " " $4 ":" $5 ":" $6   cmd = "TZ=\"America/Los_Angeles\" date -d \"" timestamp " UTC\" \"+%Y-%m-%d %H:%M:%S %Z\""   cmd | getline converted   close(cmd)   print converted }'

Using a SOAP service as DLL

By default, when you do an Add Service Reference operation, the WCF runtime will generate the client-side proxy for you. The simplest way to use it is to instantiate the client proxy with a constructor that takes no parameters, and just grab the info from the app.config : YourServiceClient proxy = new YourServiceClient(); This requires the config file to have a <client> entry with your service contract - if not, you'll get the error you have. But the client side proxy class generated by the WCF runtime also has additional constructors - one takes an endpoint address and a binding, for instance: BasicHttpBinding binding = new BasicHttpBinding(); binding.Security.Mode = BasicHttpSecurityMode.Transport;  EndpointAddress epa = new EndpointAddress("http://example.com/api/?wsdl"); YourServiceClient proxy = new YourServiceClient(binding, epa); With this setup, no config file at all is needed - you're defining everything in code. Of course, you can also s...

Installing Nginx for PHP, MySQL

Nginx is a high performance HTTP server. It provides very fast speed of delivering web pages, and uses fewer resources at the same time. With Nginx (Pronounced Engine X) A server with low resources will be able to serve many more clients, due to this, many popular websites use this (To conserve their resources, of course). In this blog post, I am going to discuss how to install Nginx, along with PHP, and MYSQL. You will need to follow very close attention to this article, else, one mistake and you may need to restart all over again. The first thing you will need to do of course is own a VPS/Dedicated server. You will also need to have an SSH Client (Putty), and your username and password. If you have all of this, the first thing you need to do is login to your panel, and rebuild the server with some version of CentOS (it does not matter what version, really). Once you have done so, login to your SSH client, supplying the required information. Next, we are going to begin the actu...