Cookies on this site

We would like to use cookies to understand how the site is used and to measure our campaigns. Nothing is set until you choose, and you can change your mind at any time from “Cookie settings” at the foot of every page. Privacy policy

Contact UsContact Us

Resources / Blogs

Cloud & apps

Basics of Vi editor in Unix

The VI editor is a fast and powerful text editor of Unix system. VI does not contain any menu, instead it uses combinations of keystrokes to accomplish an action. Here I am sharing some useful information about VI editor.

· · 2 min read

Linux Code

Modes in Vi editor
Vi has two modes.
1. Command mode- Here you can insert Vi commands. Press Ecs to enter command mode.
2. Insert mode- Here you can insert text. Press i to go to insert mode.

Starting VI editor
Open terminal and type vi followed by a file name. Hit return to enter into the editor. For example,
vi filename.txt

Save and exit VI editor

:w

save file without quitting

:q

quit without saving

:wq

save and quit


Moving the cursor

j or <Return>

move cursor down one line

k

move cursor up one line

h or <Backspace>

move cursor left one character

l or <Space>

move cursor right one character

0 (zero)

move cursor to start of current line (the one with the cursor)

$

move cursor to end of current line

w

move cursor to beginning of next word

b

move cursor back to beginning of preceding word

:0<Return> or 1G

move cursor to first line in file

:n<Return> or nG

move cursor to line n

:$<Return> or G

move cursor to last line in file

Adding or inserting text

i

insert text before cursor

I

insert text at beginning of current line

o

open and put text in a new line below current line

O

open and put text in a new line above current line

a

append text after current cursor position

A

append text to end of current line

Deleting text

x

delete single character in current cursor position

Nx

delete N characters, starting with current cursor position

dw

delete the single word beginning with current cursor position

dd

delete entire line at current cursor position

dNd or Ndd

delete N lines, beginning with the current line; e.g., 4dd deletes 4 lines

dNw

delete N words starting at current cursor position; e.g., d7w deletes 7 words

D

delete the remainder of the line, starting with current cursor position

Copying and Pasting

yy

copy (yank, cut) the current line

Nyy or yNy

copy (yank, cut) the next N lines, including the current line

p

paste the copied line/lines into the editor after the current line

Searching text

/string

search forward for occurrence of string

?string

search backward for occurrence of string

n

move to next occurrence of search string

N

move to next occurrence of search string (opposite direction)

Princeton IT is the leading software development company in USA. Get in touch!

← All articles

Case studies

Cloud Consulting in practice

Client names are withheld. We are happy to share details on a call.

All case studies
  • Delivered

    On-prem → Amazon RDS

    Nonprofit

    Cloud Consulting

    Oracle from on-premises to Amazon RDS for a national nonprofit

    The nonprofit's on-premises Oracle database had become hard to maintain and scale. We planned the move with automated workflows and validation tests, migrated to Amazon RDS for Oracle with minimal disruption and left a repeatable process for future changes.

    • Automated, tested migration
    • Less day-to-day database upkeep
  • Delivered

    600k files, < 3 days

    Document management

    Microsoft

    600,000 documents moved from ImageRight to SharePoint in under three days

    A one-file-at-a-time script would have needed about 22 days of continuous running. We rebuilt the migration around a SQL work queue with parallel uploads, automatic retries and crash recovery, and it finished unattended in under three days.

    • 1,125 → 8,314 files per hour
    • Under 3 days instead of about 22
  • Delivered

    Every change, flagged

    Food manufacturing

    AI Consulting

    Label comparison agent for a national food cooperative

    Compares two versions of a product label, highlights every change, annotates the PDF and returns an audit-ready list of differences. We moved it from Copilot Studio to Azure Functions when the document processing outgrew the low-code platform.

    • Audit-ready differences in one chat turn
    • Rebuilt from low-code to cloud functions

Keep reading

All Cloud & apps articles

Moving an application to the cloud?

Request a migration plan consult. We will scope the move with you and come back with a fixed-scope plan.