brew install neovim
- Open a file in vim editor using
vi <path_to_file_name>
- 4 modes
- normal mode ~ just move cursor around
- insert mode ~ can type regular editor
- visual mode ~ highlighting with cursor
- command mode ~ pressing
:
:w
~ save the editor:q
~ quite the editor
- practice command with game:
:VimBeGood
- Need to add this plugin
- press
dd
at linehjkl
, this will start a game. This game helps to build muscle memory
Called as Vim motion
. Motion is anything that moved motion
h
- move leftj
~ move downk
~ move upl
- rightw
- moves forward with per every wordb
- moves backward per every wordd
- deletedd
- delete current lineu
- undoctlr + r
- redo previous action
Examples:
8k
- takes the cursor:luc_arrow_big_up:
8 timesUP
in the file16j
- takes the cursor :luc_arrow_big_down: 16 times in the file7dd
- deleted 7 lines :luc_arrow_big_down: from line where your cursor is3u
- undo the last3 changes in the file
-
a
- moves cursor to the right side of the curosr- Generally when we enter into insert mode,
vim
types the characters on the left side of the cursor
- Generally when we enter into insert mode,
-
v
- Visual mode- Can be used any motions we learned so far
- hit
/
in command mode and enter the string- For example:
/schema
- it takes you to the first character of first search result - to navigate down the results - lower case
n
- to navigate upwards - upper case
N
- For example:
-
- To search and replace , type
:
and then%s/<actual_string>/<new_string>/gc
g
- stands for greedy ~ means replace every occurence not just first matchc
- stands for confirmation - ask for confirmation for every replacement
- To search and replace , type
- all the above commands can be performed in command mode
- to go to starting of the file
[[
orgg
- to go to ending of the file
]]
orshift + g
- to go to certain line
<line_number>gg
~47gg
- 69G
- to go to starting of the file
copy
====yank
in vim's terminology- to copy the text we use
y
key yiw
- copy the current wordyw
- copy from cursor to the start of the next wordyb
- copy from cursor to the end of the previous wordyy
- copy the whole liney$
- copy from current cursor location to the end of the line4yy
- copy 4 lines from the line where cursor is , including current line
diw
- delete current worddw
- delete from cursor location to start of the next worddb
- delete from cursor location to end of the previous wordsdd
- delete the whole line4dd
- delete 4 lines from the where cursor is, including current lined$
- delete from current cursor location to end of the lined^
- delete from cursor location to the start of line
Space + s + f
- opens up menu for find filesgd
- go to definition of the fileTelescope keymaps
- Find all possible keymaps those can be helpful in searching and sorting
Mason
- to install any of the language server supported
Telescope help_tags
- Shows all help tags