Getting Started with C++

Basic Commands of Editor

This article will take us through the basic commands of editor which will help you in understanding this language better. Thus, some basic commands of the editor are given in the following chapter.

basic commands of editor

For Vi:

To start vi:

Example: > vi letters will be opening a new file known as a letter to edit, or if a letter already exists, open the existing file.

vi filename – edit the filename beginning at line 1

vi +n filename – edit the filename starting at line ‘n’

Next, vi +filename – edit the filename starting at the last line

vi -r filename – recover the filename when a system crashes

vi +/patter filename – edit the filename beginning at the first line comprising of the pattern

Browse more Topics Under Getting Started with C++

Command Mode v/s Insert Mode:

Insert mode is the mode to be in when we are going to insert the text into the file. Further, the command mode is the mode to be in when giving the commands. Thus, it will result in moving the cursor, delete the text, copy and paste it, save files, etc. Let’s move to other basic commands of the editor.

While entering a file, vi is in the command mode. Moreover, for entering the text, we have to enter the insert mode. Thus, if in insert mode, enter the command mode by pressing the escape key on the keyboard.

To insert text:

i – before the cursor

a – after the cursor

A – at the end of the line

o – Open a line below the current line

O – Open a line above the current line

r – Replace the current character

R – Replace characters until <ESC>, overwrite

To move the cursor:

We must have to be in the Command Mode so that we can use the commands that will move the cursor.

Examples:

8j will move the cursor down eight lines.

3w will move the cursor three words to the right side.

SPACE, l (el), or right arrow – space to the right side.

h or left arrow – space to the left side.

j or down arrow                – down 1 line.

k or up arrow – up 1 line.

w – Word to the right side.

b – Word to the left side.

$ – end of the line.

0 (zero) – the beginning of the line.

e – End of the word to the right side.

(-) – beginning of the previous line.

) – end of the sentence.

( – starting of the sentence.

} – end of the paragraph.

{ – the beginning of the paragraph.

To Delete Text:

The d command eliminates the text from the Work Buffer. Moreover, the amount detached depends on the Repeat Factor and the Unit of the measurement we enter after d.

Examples: 3dd will delete three lines starting with the present line.

3dw or d3w will delete three words.

d0 – delete to starting of the line.

dw – delete to end of the word.

d3w – delete to end of the third word.

db – delete to starting of the word.

dW – delete to the end of the blank delimited word.

dB – delete to the starting of the blank delimited word.

dd – delete the present line.

5dd – delete five lines beginning with the present line.

dL – delete through the last line on the screen.

dH – delete through the first line on the screen.

d) – delete through the end of the sentence.

d( – delete through the starting of the sentence.

x – Delete the present character.

nx – delete the number of characters identified by ‘n’.

nX – delete ‘n’ characters before the present character.

FAQs on Basic Commands of Editor

Question 1: How can we edit in C++?

Answer: Editing C and C++ Source Files are as follows:

  • Choose Tools > Options.
  • Click Editor in the top pane of the window.
  • Click the Formatting tab.
  • Select the C++ language from the Language drop-down list.
  • Select the style we want to set from the Style drop-down list.
  • Modify the style properties as we want.

Question 2: Name any IDE for C++?

Answer: Eclipse, is one of the most popular and well-known powerful IDE for C++.

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.