How to Code with vim

 

Switch lines

  • Step 1: Position the cursor on the line you want to move.
  • Step 2: Type dd to cut the entire line.
  • Step 3: Move the cursor to the desired position.
  • Step 4: Type p to paste the line below the current line, or type P to paste the line above the current line.

Example:

  • To move line 2 to line 4:
  1. Navigate to line 2.
  2. Type dd (line is cut).
  3. Navigate to line 4.
  4. Type p (line is pasted below line 4).

Save the file

  • Step 1:press "esc"
  • Step 2: Type ":w" ,to write changes.
  • Step 3: Type ":wq", to write and quit.

Undo

  • Step 1:press "esc"
  • Step 2: Type ":u"

Open a Terminal Inside Vim

  1. Enter Command Mode: Press Esc to ensure you're in normal mode.

  2. Open the Terminal: Type the following command and press Enter: ":term"

  3. To write press "i"

  4. When done type "exit"  press enter

  5. Then press "esc" to close the buffer.

Comments

Popular posts from this blog

Bug Boundy Methodology, Tools & Resources

Install & set up mitmweb or mitmproxy in Linux

Day 20: Search in Rotated Sorted Array: Binary Search - leetcode - Python3