Showing posts with label Linux Vi Editor Commands. Show all posts
Showing posts with label Linux Vi Editor Commands. Show all posts

Sunday, 20 January 2013

How to open multiple files in Vi editor

Suppose if you want to open multiple files in Vi editor than do the following commands

CTRL + W + s - That means it will open the same file(whatever file you opened currently for example if you open one file currently) again and the window split into Horizontally.

CTRL + W + v - That means it will open the same file in vertical manner.

After that if you want to open the new file on splinted window than do the following commands

:e <path of the file name> - It will open new file whatever you mentioned in the path.

Switch between multiple files:

ctrl + w + w - means it will go to next file(next tab). If you keep on pressing, you can easilly navigate which file you want to work.

ctrl+w+(h j k l) - It means it will navigate through you desired position either LEFT DOWN UP RIGHT manner.

How to close the opened multiple files

ctrl - w - o - It means it will close all windows other than current file(cursor located/pointing file).
ctrl - w - c - It means it will close only current window file not rest of them.

Wednesday, 9 January 2013

Linux Vi editor basic commands

 This article will help you, if you are very beginner in Vi editor in Linux platform.

Here is the list of commands for your reference.

* Cursor movement commands

h - left side single character move
j  - down by one line from current cursor position
k - Up one line above from the current cursor position
l  - Right side single character move

* file Edit commands
  * vi +5 <file name> - It will open the file then the cursor position will stay on line no 5( 5 is just example only)

* Search related commands
  * vi +/string - It will open the file and search the given string after that cursor will stay on first occurrence of the given string.

 *  /<string> - It will find a string in the forward way. If you want to next find then press "n"
 * ?<string> - It will find a string in backward way. similarly if you want to find next then press "n"

* Insertion commands
  o(alphabetical letter) - It will insert one line below the current cursor position.
  O(alphabetical letter) - It will insert one line above the current cursor position.

* Delete commands
  dd - It will delete one line from your current cursor position.
  5dd - It will delete 5lines from your current cursor position.(5 is just example only)

* Copy  commands
  yy - It will copy current cursor line.
  5yy - It will copy 5 lines from current cursor position line.(5 is just example only)

* Paste command
  p - It will paste whatever you copied.

* Word jumping/movement
   w - it will move one word to next word (cursor position will be at starting of the string)
    b - Back to previous word (cursor position will be at starting of the string only)
    e - Move to next word (cursor position will be end of the next word)

* Goto Line no :
 ESC then type :<line no>


NOTE : WHENEVER YOU DO THIS COMMANDS BETTER PRESS "ESC" COMMAND TWICE THAT FOR YOU ARE MAKE SURE YOU ARE IN COMMAND MODE. THAN ONLY THE ABOVE COMMANDS WILL EXECUTE.