×

Vim Editor Session

~SriBhavani and Bakyalakshmi

On 18th Jan 2022, we had a session on vim by HarshaVaradhan from AuraSemiconductors. In this blog, we share what we have learned about vim and how we use it.

Introduction:

Vim is a highly configurable text editor built to create and change any kind of text very efficiently. Vim Editor has its own configuration file called vimrc.  This can be customizable based on how we want to see GVIM

  • Vim has the Two modes of operation
    • Command Mode
    • Insert Mode

Command Mode:

To enter into the command mode press ESC.

There are two sub-modes in the command mode.

  1. Command Line Editing 🡪  “:” followed by the command

(eg) :q- to quit the editor window

  1. Command-line window 🡪 Directly enter the command It will automatically execute once it got the valid sequence

(eg) dd – delete the current line

Insert Mode:

There are two ways to enter into insert mode.

  1. i 🡪 Enter into the Insert mode at the point where the cursor present
  2. o 🡪 Enter into the Insert mode with the new line, next to the Cursor line

Few commands to access vim editor in the Command line window:

  • dd 🡪 Delete the cursor line. 
  • ndd 🡪 Delete the n lines from the cursor position
  • gg 🡪 Go to File Starting. 
  • GG 🡪 Go to End of the File.
  • Ngg 🡪 Go to nth line in the file.
  • yy 🡪 Copy the Cursor line
  • Nyy 🡪 Copy N lines from the cursor line
  • u 🡪 undo the changes
  • ctrl+R 🡪 Redo the last changes
  • ggVG 🡪  This will select all the file data
  • y 🡪 copy the selected content
  • p 🡪 paste copied content

 

Few commands to access vim editor in Command Line Editing

  • :w 🡪 To save the file
  • :q! 🡪 close the editor without saving the changes
  • :vsp 🡪 Split the same vim editor file in two windows vertically
  • :sp 🡪 Split the same vim editor file in two windows Horizontally
  • :tabnew 🡪 Open newtab
  • :E 🡪 To open the file tree
  • :se nu 🡪 Show line numbers in the text editor
  • :se nonu 🡪 Remove line numbers in the text editor

 

Search 

  • Type ” / “  to search a word or sentence in command mode

(e.g.) /cat – it will highlight all occurrence of word “cat” in the file

  • n 🡪 show next occurrence from current to bottom
  • N 🡪 Show search word occurrence from current to top

Search and replace: 

:%s/Old/New/gc Search for word “Old” and replace by “New”, ask confirmation before replace
:%s/old/NEW/gi Case insensitive, Search all possibilities of word “old” and replace by “NEW”
:%s/Old/New/gI Case sensitive, Search “Old” replace by “New”
:%s/Old/New/g Replace all occurrence of “Old” by “New”, without asking for confirmation 

 

Author

prathap7618@gmail.com

Related Posts

Shifu: Weekly Presentation

Sandhiya Saravanan, Vaishnavi K, Abinaya K, Preethi P, Gunavathi S, Poonguzhali, Ajay I, Tamil, Premkumar, Soundhariya, Kugan, DuraiSamy, SandhiyaBala Learning at Shifu...

Read out all

Growing Together: Our Saturday Garden Activities

Every Saturday from 2:30 to 3:30 pm, we had garden activities in our office. It was a special time when we all...

Read out all

Auroville Joins the International Day of Yoga – My Two-Day Journey of Energy and Awareness

-SandhiyaBala, Sivaguru and Ajay I This year, Auroville joined people around the world in celebrating the International Day of Yoga on June...

Read out all

Auroville Cyclothon: More Than Just a Ride

-Preethi R and Nithya Santhosh At STEM Land we each explore our learning and growth and Auroville presents us many opportunities. A...

Read out all

Garden clean up with teams

~ Saranya, Kethsiyaal, Poovizhi, Arun Kumar, Sri Bhavani This team activity takes place every Saturday. We come together and work as a...

Read out all

15TH -AUROVILLE MARATHON 2025

-Sivaguru, Sandhiya Bala, Sribhavani, Preethi R, Preethi P, Andreas, Aarthi, Patchaiyappan, Nithya Sandhosh, Ilakiya and Durai One of our core values is...

Read out all