Skip to main content

Unix Vi Editor commands

To Start vi
1. vi filename Create or Edit filename starting at line 1
2. vi -r filename Recover filename that was being edited
when system crashed

To Exit vi
1. :x<return> Quit vi, writing out modified file to file
named in original invocation
2. :wq<return> Quit vi, writing out modified file to file
named in original invocation
3. :q<return> Quit or exit vi
4. :q!<return> Quit vi even though latest changes have not
been saved for this vi call

 cursor Movment
1. j or <return>
[or down-arrow]
Move cursor down one line
2. k[or up-arrow] Move cursor up one line
3. h or<backspace>
[or left-arrow]
Move cursor left one line
l or<space>[or right-arrow] Move cursor right one line
4. 0(zero) Move cursor to start of current line(the one
with the arrow)
5. $ Move cursor to end of the current line
6. w Move cursor to beginning of next word
Basic vi commands7. b Move cursor back to beginning of preceding
8. :0<return> or 1G Move cursor to first line in file
9. :n<return>or nG Move cursor to line n in file
10. :$<return>or G Move cursor to last line in file

Screen movement
1. ^f Move forward one screen
2. ^b Move backward one screen
3. ^d Move down(forward) one half screen
4. ^u Move up(back)one half sreen
5. ^l Redraws the screen
6. ^r Redraws the screen,removing the deleted

Text Editing
1. u Undo whatever you just did(a simple toggle)
Inserting or Adding text
1. i Insert text before cursor,until<esc>hit
2. I Insert text at beginning of current
3. a Append text after cursor,until<esc>hit
4. A Append text to end of current
5. o Open and put text in a new line below
current line,until<esc>hit
6. O Open and put text in a new line above
current line,until<esc>hit

Basic vi commandsChanging the text
1. r Replace single character under cursor(no
2. R Replace characters,starting with current
cursor position,until<esc>hit

3. cw Change the current word with new
text,starting with the character under

4. cNw Change N words beginning with the
character under cursor,until<esc>hit

5. c change(replace)the characters in the current line,until<esc>hit

6. cc change(replace)the characters in the current line,stopping when <esc>hit

7. Ncc or cNc change(replace)the next N lines,starting
with the current line,stopping when

Deleting the text
1. x Delete single character under cursor
2. Nx Delete N characters, starting with character
under cursor
3. dw Delete the single word beginning with
character under cursor
4. dNw Delete N words beginning with character
under cursor
5. D Delete the remainder of the line,starting
with current cursor position
6. dd Delete entire current line
7. Ndd or dNd Delete N lines beginning with the current
Basic vi commandsCutting and pasting the text
1. yy Copy (yank,cut) the current line into buffer
2. Nyy or yNy copy(yank,cut) the next N lines,including
the current line, into the buffer
3. p put(paste) the lines in the buffer into the
text after the current line

Searching the text
1. /string Search forward for occurence of string in text
2. ?string Search backward for occurence of string in text
3. n Move to next occurence of search string
4. N Move to next occurence of search string in opposite direction

Determining line numbers
1. :.= Returns line number of current line at bottom of screen
2. := Returns the total number of lines at bottom of the screen
3. ^g Provides the current line number, along with the total number of lines,in the file at the bottom of the screen

Saving and reading files
1. :r filename<return> Read file named filename and insert after
current line(the line with arrow)

Basic vi commands

2. :w<return> Write current contents to a file named in
original vi call

3. :w newfile<return> Write current contents to a new file named

4. :12,35w smallfile<return> Write the contents of the line numbered 12
through 35 to a new file named smallfile
5. :w! prevfile<return> Write current contents over a pre-existing
file named prevfile


Popular posts from this blog

Conversion from Clob To String in java and Vice versa

/***reading Clob data from oracle table and setting to Pojo**/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import oracle.sql.CLOB;


public class MessageDao {
private static String url = "jdbc:oracle:thin:@";
private static String username = "ABC123";
private static String password = "ABC123";

public  List readClobToBO() throws Exception {

Connection conn = DriverManager.getConnection(url, username, password);
PreparedStatement stmt = conn
ResultSet resultSet = stmt.executeQuery();
List msgList= new ArrayList();

while ( {

StagedMessage message = new StagedMessage();


Portable Java 8/ JDK8 setup without admin rights

Some time we got machine to work where we don't have access rights to install anything or if you do not want to install. You can get latest jdk running by this trick. Just follow step step & do comment if you like it.

Step by Step details to get running java from .exe setup without any admin rights. Get portable 7 zip from portableapps.comdownload java 8 from oracle 7 zip & extract jdk-8u102-windows-x64.exeyou will see below folders                .data                .pdata                .rdata                .reloc                .rsrc                .text                CERTIFICATE

          5.Go inside E:\jdk-8u102-windows-x64\.rsrc\1033\JAVA_CAB10you will find 111 file.

         6.extract it it some folder where you can find again extract that to some folder say Java & copy it to very first folder of setup along with .data,.rsrc etc.
         7.Go to folder where you have co…

Multi Threading , Producer consumer problem in Java

Multi threading is topic which is always fascinating for java developer. I feel its more about practical the theory. So here i wanted to present sample examples which clear understanding for several multi threading concept.

In Theory basically thread which is light weight process.Thread shares mostly same memory space.
I said mostly because there is some space called thread local which is not common to threads & separate for each thread. We create thread whenever we wanted to use multicore of processor although that doesn't mean single core cant use it. In single core context switching works among different running thread.

for example suppose there is website which is showing latest price as well as offer as well as doing order booking all these things can be assigned to different thread to provide parallel processing.

There are 2 ways for creating a thread.

Extend a thread & Implement a Runnable class. Extending a class is little avoided since it closed possibility for e…