Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

Linux IntroductionChapter 3. Vim Editor

Chapter 3. Vim Editor

How to Use Vim Editor for Text Editing on Linux

In this chapter, we’ll explore Vim, a powerful text editor that is built into Linux systems. Vim is widely used for text editing in programming and system administration due to its speed, efficiency, and ability to handle large files with ease. Whether you’re new to Vim or looking to master its powerful features, this chapter will walk you through all the essential aspects of using Vim effectively in the Linux terminal.

What We Cover in This Chapter

The following topics are covered in this chapter:

What Is Vim and How to Launch It?

In this section, we’ll introduce Vim as an open-source Unix and Linux text editor. We’ll cover how to launch Vim, whether you’re working locally or remotely, and explore the basic differences between Vim and other text editors.

Normal, Insert and Visual Mode

Vim operates in three primary modes: Normal mode, Insert mode, and Visual mode. In this section, we'll explain each mode in detail, including how to switch between them and what actions are available in each mode. Understanding these modes is crucial for efficiently using Vim.

Normal Mode (1) – Move Cursor

In this section, we’ll explain how to navigate your file using the keyboard in Normal mode. You’ll learn how to use arrow keys and other shortcuts like k, j, h, and l to move the cursor. We’ll also cover how to jump to specific lines, move by words, and change pages.

Normal Mode (2) – Delete

Deleting text in Normal mode is simple and efficient. We’ll cover various ways to delete text, such as using the x key to delete a character, dd to delete a line, and how to delete multiple lines or text from a specific part of a line.

Normal Mode (3) – Copy and Paste

In this section, we'll show you how to copy (yank) and paste text in Normal mode. You’ll learn how to copy a line, multiple lines, and paste them at the desired location using the p or P command.

Normal Mode (4) – Undo and Redo

We’ll explain how to undo changes using the u command and redo them using Ctrl + r. Understanding undo and redo in Vim is key to quickly correcting mistakes without losing work.

Normal Mode (5) – Search Phrase

In this section, you’ll learn how to search for specific text within your document. We’ll cover how to use the / and ? commands to search forward and backward, and how to navigate through search results using n and N.

Normal Mode (6) – Replace Phrase

Learn how to replace specific phrases in your file. We’ll demonstrate the command for replacing a word or phrase with another, either across the entire document or within a specific line or section.

Normal Mode (7) – Save and Exit

Saving your work and exiting Vim are common tasks. In this section, you’ll learn how to use the :w command to save changes, :q to quit, and :wq to both save and quit. We’ll also explain how to force quit without saving changes using :q!.

Insert Mode

In Insert mode, you can freely add and delete text. We’ll explore the different ways to enter Insert mode and the various options available, such as using i to insert before the cursor or a to append after the cursor.

Visual Mode

Visual mode allows you to select text as a block for copying, deleting, or modifying. You’ll learn how to start Visual mode with v, select entire lines with V, and use the selected text for various actions like changing the case or copying it to another location.

Learn offline for better focus!
A book for this course is available on Amazon.

Linux Visual Guide

Step-By-Step Manual for Complete Beginners to Mastering Linux Basics, Vim Editor, Command Management, Remote Server Operation, and More.

Your browser does not support the video tag.
Get the Book Now

More Topics to Explore

URL Dispatching in Django for CRUD Operations

URL Dispatcher for CRUD Views

Understanding the Role of Operating Systems

What Is OS?

URL Dispatching in Django for CRUD Operations

URL Dispatcher for CRUD Views

Understanding the Role of Operating Systems

What Is OS?

Tags:

Text Editor

Linux

Vim

Linux Introduction
Course Content

Chapter 1. Linux Basics

What Is OS?

CUI and GUI

Linux Distributions

Package Manager

Kernel and Shell

Current Working Directory

Linux Directory Structure

Absolute Path and Relative Path (Linux OS)

Linux Command Syntax

Special Characters and Escape Character

Chapter 2. Linux Key Commands

Setting Up Linux Environment on AWS

pwd (Print Working Directory)

cd (Change Directory)

ls (List Contents of Directory)

mkdir (Make Directory)

rmdir (Remove Directory)

touch (Create File)

rm (Remove File)

mv (Move File and Directory)

cp (Copy File and Directory)

cat (Display File Content)

sort (Sort File Contents)

grep (Global Regular Expression Print)

Regular Expression

find (Find File and Directory)

Wildcard

ln (Create Link to File and Directory)

Chapter 3. Vim Editor

What Is Vim and How to Launch It?

Normal, Insert and Visual Mode

Normal Mode (1) – Move Cursor

Normal Mode (2) – Delete

Normal Mode (3) – Copy and Paste

Normal Mode (4) – Undo and Redo

Normal Mode (5) – Search Phrase

Normal Mode (6) – Replace Phrase

Normal Mode (7) – Save and Exit

Insert Mode

Visual Mode

Chapter 4. User, Group and Permission

What Are User, Group And Permission in Linux?

Permission (Access Mode) by Owner Status

Superuser (Root User) vs. Normal User

sudo (Run Command with Superuser Privileges)

su (Switch User)

useradd (Add User)

passwd (Set Password)

userdel (Delete User)

Group – Primary Group and Secondary Group

groupadd (Add Group)

usermod (Modify User Account Information)

gpasswd (Add and Delete Users to Group)

groupdel (Delete Group)

chown (Change Owner of File and Directory)

chgrp (Change Group of File and Directory)

chmod (Change Access Mode)

chmod Command with Numbers

w and who (Check Current User Login Status)

id and groups (Check User ID and Group)

getent (Display User and Group Data)

Chapter 5. Redirection, Pipe and Shell Script

Standard Input Output and Redirection

Pipe (Combine Commands)

less (Display Content with Pager)

tr (Replace Characters)

cut (Extract Data Sections)

uniq (Extract Unique Data Lines)

Shell Script

echo (Echo input)

read (Read and Store Input)

Shell Variable and Environmental Variable

source (Execute Shell Script and Refresh Environmental Variables)

Chapter 6. Linux Commands for Command Management

history (Check Command History)

alias (Create Command Shortcuts)

man (Display Manual)

type, which and whereis (Display Command Information)

Package Manager Command

tree (Display Directory Tree)

Chapter 7. SSH Remote Connection

SSH (Secure Shell)

Locate .ssh Directory

SSH Remote Login (1) – Use Key Pair Generated by Server

SSH Remote Login (2) – Use Key Pair Generated by Client

SSH Config File

SSH Remote Login with Visual Studio Code

SCP (Secure Copy Protocol)

SCP with SSH Config File

SFTP (Secure File Transfer Protocol)

Other File Transfer Commands

Chapter 8. Linux Process Management

Process and Job

Foreground and Background Jobs

jobs and ps (Display Jobs and Processes)

Signals

Create, Stop and Terminate Jobs

Daemon Processes

What Is Service on Linux?

Systemd

Unit File

Systemctl Sub-Commands

Create Custom Unit and Start at Boot

Firewall

UFW (Uncomplicated Firewall)

Web Server

Launch Apache Web Server

Chapter 1. Linux Basics

What Is OS?

CUI and GUI

Linux Distributions

Package Manager

Kernel and Shell

Current Working Directory

Linux Directory Structure

Absolute Path and Relative Path (Linux OS)

Linux Command Syntax

Special Characters and Escape Character

Chapter 2. Linux Key Commands

Setting Up Linux Environment on AWS

pwd (Print Working Directory)

cd (Change Directory)

ls (List Contents of Directory)

mkdir (Make Directory)

rmdir (Remove Directory)

touch (Create File)

rm (Remove File)

mv (Move File and Directory)

cp (Copy File and Directory)

cat (Display File Content)

sort (Sort File Contents)

grep (Global Regular Expression Print)

Regular Expression

find (Find File and Directory)

Wildcard

ln (Create Link to File and Directory)

Chapter 3. Vim Editor

What Is Vim and How to Launch It?

Normal, Insert and Visual Mode

Normal Mode (1) – Move Cursor

Normal Mode (2) – Delete

Normal Mode (3) – Copy and Paste

Normal Mode (4) – Undo and Redo

Normal Mode (5) – Search Phrase

Normal Mode (6) – Replace Phrase

Normal Mode (7) – Save and Exit

Insert Mode

Visual Mode

Chapter 4. User, Group and Permission

What Are User, Group And Permission in Linux?

Permission (Access Mode) by Owner Status

Superuser (Root User) vs. Normal User

sudo (Run Command with Superuser Privileges)

su (Switch User)

useradd (Add User)

passwd (Set Password)

userdel (Delete User)

Group – Primary Group and Secondary Group

groupadd (Add Group)

usermod (Modify User Account Information)

gpasswd (Add and Delete Users to Group)

groupdel (Delete Group)

chown (Change Owner of File and Directory)

chgrp (Change Group of File and Directory)

chmod (Change Access Mode)

chmod Command with Numbers

w and who (Check Current User Login Status)

id and groups (Check User ID and Group)

getent (Display User and Group Data)

Chapter 5. Redirection, Pipe and Shell Script

Standard Input Output and Redirection

Pipe (Combine Commands)

less (Display Content with Pager)

tr (Replace Characters)

cut (Extract Data Sections)

uniq (Extract Unique Data Lines)

Shell Script

echo (Echo input)

read (Read and Store Input)

Shell Variable and Environmental Variable

source (Execute Shell Script and Refresh Environmental Variables)

Chapter 6. Linux Commands for Command Management

history (Check Command History)

alias (Create Command Shortcuts)

man (Display Manual)

type, which and whereis (Display Command Information)

Package Manager Command

tree (Display Directory Tree)

Chapter 7. SSH Remote Connection

SSH (Secure Shell)

Locate .ssh Directory

SSH Remote Login (1) – Use Key Pair Generated by Server

SSH Remote Login (2) – Use Key Pair Generated by Client

SSH Config File

SSH Remote Login with Visual Studio Code

SCP (Secure Copy Protocol)

SCP with SSH Config File

SFTP (Secure File Transfer Protocol)

Other File Transfer Commands

Chapter 8. Linux Process Management

Process and Job

Foreground and Background Jobs

jobs and ps (Display Jobs and Processes)

Signals

Create, Stop and Terminate Jobs

Daemon Processes

What Is Service on Linux?

Systemd

Unit File

Systemctl Sub-Commands

Create Custom Unit and Start at Boot

Firewall

UFW (Uncomplicated Firewall)

Web Server

Launch Apache Web Server