Skip to content

Instantly share code, notes, and snippets.

@SantoshCode
Last active March 17, 2022 16:03
Show Gist options
  • Save SantoshCode/f8ae4a8ecf0cee7dc287a1a2b54830b0 to your computer and use it in GitHub Desktop.
Save SantoshCode/f8ae4a8ecf0cee7dc287a1a2b54830b0 to your computer and use it in GitHub Desktop.
Learning vim commands

https://theprimeagen.github.io/vim-fundamentals/

Opening neovim config file

:echo stdpath("config") // get the path

:set scrolloff=8

:set relativenumber or :set rnu

:set number

d6j delete 6 down in relative number mode

V6jd highlight and delete 6 down line

Split view

Ctrl+w window mode and then v for vertical, s for split horizontal

Bookmark locally and globally

Locally

Place cursor on line and then m + <lowercase>

Globally

Place cursor on line and then m + <uppercase>

Navigating between bookmarks

' <caseletter>'

Note: lowercase only works within the file (it is local)

Go back and forth between current and previous file

Ctrl + 6

Hopping back of my jump list (helps in navigating to previous edit position)

Ctrl + o

Hopping up of my jump list

Ctrl + i

A deleting trick in vim

Shift + d delete everything to right of cursor in a line.

see files that weren't source controled using fzf

:Files

While in this mode Ctrl + n goes next in the list Ctrl + p will go previous in the list

see files that were source controled using fzf

:GFiles

While in this mode Ctrl + n goes next in the list Ctrl + p will go previous in the list

Quick fix list

Search some keyword in whole project folder and fix/edit them by keeping all files in a quick fix list.

:grep SOCKET **/*.c

Press Enter

:cnext to move to next result

:cprev to jump to previous result

You can remap :cnext and :cprev to C-j and C-k

How to see quick fix list again? Use :copen

We can also pipe changes, macro to all quick fix list using :cdo and wa

Search and Replace

:/<keyword>

n to go to next search N get back

Delete upto "

di"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment