Skip to main content

Mastering the VI Editor: A Comprehensive Usage Guide for Linux Enthusiasts

VI Editor: Usage Guide

Aim:

Learn how to use the VI editor for various text editing tasks.

VI Editor: Usage Guide

Guidance on How to Use VI Editor:

i. Edit the File:

To open a file in VI for editing, use the following command:

vi filename.txt
Once in VI:
  • To enter edit mode, press 'i'.
  • To save changes, press 'Esc', then type ':w' and press 'Enter'.
  • To exit VI, press 'Esc', then type ':q' and press 'Enter'.
  • If changes are made and you want to save and exit, type ':wq' and press 'Enter'.

ii. Search Specific Content:

While in command mode (press 'Esc'), use the following command to search for specific content:

:/search_text
To navigate through search results, press 'n' for the next occurrence.

iii. Replace Specific Content:

To replace specific content, use the following command in command mode:

:%s/old_text/new_text/g
This replaces all occurrences of old_text with new_text in the entire file.

iv. Search Content with Special Characters:

To search for content containing special characters, use the following command:

:/@gmail\|\/hms\/logs\|"4
This searches for lines containing @gmail, /hms/logs, or "4.

v. Delete Multiple Lines:

To delete multiple lines, use the following command in command mode:

:1,5d
This deletes lines 1 to 5. Adjust the line numbers as needed.

vi. Select Multiple Lines in Separate File:

To select and copy multiple lines to a separate file, use the following steps:

  • Move the cursor to the starting line.
  • Press 'v' to enter visual mode.
  • Move the cursor to select lines.
  • Press 'y' to copy the selected lines.
  • Open a new file using 'vi newfile.txt'.
  • Press 'p' to paste the copied lines.
  • Save and exit as mentioned in the editing steps.

Verification:

Verify your changes and save the file:

:wq

Written by: A.M.Rinas

Contact: mohomadrinas00@gmail.com

Comments

Popular posts from this blog

Use Katalon Studio in ubuntu

How to Install and Use Katalon Studio for Web Testing Step-by-Step Guide to Installing Katalon Studio Katalon Studio is a powerful tool for automating web, API, and mobile testing. In this guide, we'll walk you through the installation process and show you how to create your first test case for a web application. Step 1: Download Katalon Studio Start by downloading the latest version of Katalon Studio from the official website. Choose the version that suits your operating system. Step 2: Extract and Run the Application Once the download is complete, extract the contents of the downloaded file. Inside the extracted folder, locate the katalon.sh file (for Linux users) and run it to launch Katalon Studio: ./katalon If you're on Windows...

A Step-by-Step Guide to Installing XMIND on Ubuntu

Installing XMIND on Ubuntu Problem: Installing XMind on Ubuntu for Mind Mapping and Visualization Installing XMind on Ubuntu: A Comprehensive Guide Mind mapping is a powerful technique for visualizing thoughts, ideas, and information. XMind is a popular tool that provides a user-friendly platform for creating mind maps. In this guide, we will walk through the steps to install XMind on Ubuntu, enabling you to harness the benefits of this versatile mind mapping tool. Guidance on How to Install: Prerequestic: Sometimes you have to install snap store, for that type following command. Install snap store in Ubuntu: sudo snap install snap-store Follow these steps to install XMIND on Ubuntu successfully: Open a terminal window.(Ctrl+Alt+T) Run the following command to upd...

Creating a Docker Network for Container Communication

Essential SQL Queries for Database Exploration and Management | By A.M.Rinas How to Create a Docker Network Creating a Docker network allows containers to communicate with each other while isolating them from external traffic. This is particularly useful for managing services that need to interact within a defined network. Follow these steps to create a Docker network: Step 1: Open Your Terminal Access your terminal or command prompt where Docker is installed. Step 2: Create a Docker Network Use the following command to create a new Docker network: docker network create your_network_name Replace your_network_name with a name that makes sense for your application. Step 3: Verify the Network Creation You can verif...