top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Basics of Vi editor

+1 vote
375 views

What is vi editor?

Vi means Visual Editor.It is used to edit the unix files
There are many ways to edit files in Unix and Vi is one of the best ways is using screen-oriented text editor vi.
This editor enable you to edit lines in context with other lines in the file.

Now a days people using advanced version of Vi called VIM.

How to start vi editor
You can use the following commands and use the vi editor.

vi filename

It Creates a new file if it already does not exist, otherwise opens existing file.

vi -R filename

Opens an existing file in read only mode.

view filename

Opens an existing file in read only mode.

Example for Creating Vi

$vi sample

Then you can see the following screen as a result.From there you can edit your codes.

~
~
~
~
~
~
~
~
~
~
~
"sample" [New File] 

How to quit the vi

Using the following command you can come out of the vi

:q

This command will used to come out of vi without saving the content.

How to save the content in vi

:w

Above command will used to save the vi content.

Also,You can use :wq.This will use to save and quit immediately.

Some of the commands which will use inside the file while typing like move up,down,left,right

k ->Moves the cursor up one line.
j ->Moves the cursor down one line.
h ->Moves the cursor to the left one character position.
l ->Moves the cursor to the right one character position.

Copy and paste commands

yy ->Copies the current line.
yw->Copies the current word from the character the lowercase w cursor is on until the end of the word.
p ->Puts the copied text after the cursor.
P ->Puts the yanked text before the cursor.

For More -> Visit this link http://www.tutorialspoint.com/unix/unix-vi-editor.htm

posted Sep 3, 2014 by Manish Tiwari

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

What is nano?

nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality.

GNU nano is a small and friendly text editor. Besides basic text editing, nano offers many extra features like an interactive search and replace, go to line and column number, auto-indentation, feature toggles, internationalization support, and filename tab completion.

Nano has a pseudo-graphical layout that makes it a little easier to jump right into.

Command for Starting nano editor

nano newfile

Editor Window
enter image description here

Command line Options

+LINE,COLUMN
Start at line number LINE and column number COLUMN (at least one of which must be specified) instead of the default of line 1, column 1.
-?
Same as -h, --help.
-A, --smarthome
Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.
-B, --backup
When saving a file, back up the previous version of it to the current filename suffixed with a ~.
-C , --backupdir=
Set the directory where nano puts unique backup files if file backups are enabled.
-D, --boldtext
Use bold text instead of reverse video text.
-E, --tabstospaces
Convert typed tabs to spaces.
-F, --multibuffer
Enable multiple file buffers, if available.
-H, --historylog
Log search and replace strings to ~/.nano_history, so they can be retrieved in later sessions, if nanorc support is available.
-I, --ignorercfiles
Don't look at SYSCONFDIR/nanorc or ~/.nanorc, if nanorc support is available.
-K, --rebindkeypad
Interpret the numeric keypad keys so that they all work properly. You should only need to use this option if they don't, as mouse support won't work properly with this option enabled.
-L, --nonewlines
Don't add newlines to the ends of files.
-N, --noconvert
Don't convert files from DOS/Mac format.
-O, --morespace
Use the blank line below the titlebar as extra editing space.

More Reference click here -> http://mintaka.sdsu.edu/reu/nano.html

READ MORE

 SQL (Structured Query Language) is a standardized programming language used for managing relational databases and performing various operations on the data in them. Initially created in the 1970s, SQL is regularly used by database administrators, as well as by developers writing data integration scripts and data analysts looking to set up and run analytical queries.

RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and it consists of columns and rows.

SQL commands are divided into several different types, among them data manipulation language (DML) and data definition language (DDL) statements, transaction controls and security measures. 

                        

Some of The Most Important SQL Commands:

  • SELECT - The SELECT statement is used to select data from a database. 

          Syntax: SELECT column1, column2, ...
          FROM table_name;

          SELECT * FROM table_name;

  • UPDATE - The UPDATE statement is used to modify the existing records in a table.

         Syntax: UPDATE table_name
         SET column1 = value1, column2 = value2, ...
         WHERE condition;

  • DELETE – The DELETE statement is used to delete existing records in a table.

          Syntax: DELETE FROM table_name
          WHERE condition;

  • INSERT INTO - The INSERT INTO statement is used to insert new records in a table.

          Syntax: INSERT INTO table_name (column1, column2, column3, ...)
          VALUES (value1, value2, value3, ...);

  • CREATE DATABASE - creates a new database

          Syntax: create database database_name;

  • CREATE TABLE – The CREATE TABLE statement is used to create a new table in a database.

          Syntax:

          CREATE TABLE table_name (
          column1 datatype,
          column2 datatype,
          column3 datatype,
           ....
           );

  • ALTER TABLE - The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

          Syntax:

          ALTER TABLE table_name
          ADD column_name datatype;

  • DROP TABLE - The DROP TABLE statement is used to drop an existing table in a database.

          Syntax: DROP TABLE table_name;

  • CREATE INDEX - The CREATE INDEX statement is used to create indexes in tables.

          Syntax: CREATE INDEX index_name
          ON table_name (column1, column2, ...);

  • DROP INDEX - The DROP INDEX statement is used to delete an index in a table.

          Syntax: DROP INDEX table_name.index_name; 

Please go through the link:

https://www.youtube.com/watch?v=3J0n7BABEsU

READ MORE
...