Skip to content

Latest commit

 

History

History
93 lines (68 loc) · 2.89 KB

File metadata and controls

93 lines (68 loc) · 2.89 KB

vim/vi Editor:

1. vimrc Setup:

user@machine~$: touch ~/.vimrc # If doesn't exist ~/.vimrc, then create it.
set nu ic ai et ts=4 sw=4 hlsearch

 

Individual Setup (Optional):

Set Line Number: :set nu (active) and :set nu! (deactive)
Set Tab Space (ts) and Shift Wifth (sw) to 4: :set ts=4 sw=4
Set Autometic Indentation: :set ai
Set Highlight Search Results: :set hlsearch (active) and :set hlsearch! (deactive)

Note: ic --> ignore case; et --> expandtab; ts --> tabstop; sw--> shiftwidth; nu --> number

 

2. Two Basic Modes:

  1. Insert Mode/Insert Text: a, or o
  2. Command Mode: escape + : + <command>

Note-1: : implies shift +.
Note-2: Write : by using escape + shift + :.
Note-3: Write any command by using escape first.
Note-4: The + sign denotes press one after another button. (e.g., eacape + p means press the ESC button and then p.)

 

3. Open, Close, Save:

  1. Save and Quit Together: :x, or :wq (Only Save: :w, Only Quit: :q)
  2. Force Quit (without saving the file): :q!

 

4. Delete Options:

  1. Delete a Line: eacape + dd
  2. Delete Till End of a Line: eacape + d + $
  3. Delete Till Start of a Line: eacape + d + 0
  4. Delete Multiple Line (in a range): :4,8d # Delete 4 to 8 lines

 

5. Copy, Paste, Undo, Redo:

  1. Copy a Single Line: eacape + yy
  2. Copy Multiple Line (in a range): 4,8y
  3. Paste a Line: eacape + p
  4. Cut and Paste Together: eacape + dd then eacape + p
  5. Undo Text: eacape + u
  6. Redo Text: eacape + control + r

 

6. Moving Cursor:

  1. Go to the Specific Line Number: :n (e.g.,: :5, :11)

  2. Go to the Beginning of a File: :0, or :1, or eacape + [[

  3. Go to the Ending of a File: :$, or eacape + ]]

  4. Forward a Word: eacape + w

  5. Backword a Word: eacape + b

 

7. Pattern Search:

  1. Ignore Case (Before Search): :set ic
  2. Search: :/<pattern> (e.g., :/password, :/yes, :/no)
  3. Search Text and Replace: :%s/<oldText>/<newText>/g (e.g., :%s/today/tomorrow/g)
  4. Remove Highligh Text: :noh

 

8. Run Programming from vi/vim:

  1. Python Script: :!python anyName.py

 

End Notes:

Download the vim on Ubuntu:

[1]. Downloading Process
[2]. Default Parameters Setting
[3]. Downloading vim Editor

References:

[1]. Richard's
[2]. Core/Basic Commands
[3]. All Commands
[4]. Chris Toomey Talk on YouTube ***