vim. I will keep a log of things I learn in the process.
Update: I started using vim "actively" from Nov 12, 2020 and it has now been 1 month complete in Vim & I don't think I am moving to another text editor in future.
Some must know stuff filtered from the vast array of vim things.
iinsert text before the cursor position
aappend text after the cursor position (my advice, always use this instead of
Aappend text at end of line
oopen a new line after current line
Oopen a new line before current line
xdelete character under cursor
Ddelete until the end of line
rreplace the character under cursor
Rreplace stuff until we want
ddDelete current line.
ccdelete current line and switch to insert mode.
Cdelete everything from the cursor position to the EOL.
I felt like a rookie when I used to search this, anyways here is how you do it:
:"+y: for yanking(copying) text to system's clipboard.
:"+p: to paste from system's clipboard
*to select all its occurrences.
:%s//<replace-word>/to replace all the selected words.
:nohlsearch: for clearing search highlighting. Also read (:h usr_12.txt), section 12.2 for a nice overview on search.
Ctrl + gand
Ctrl + tto traverse matches while still being in search mode.
:earlier N: Time travel in past N seconds.
:later N: Time travel in future N seconds.
:echo $MYVIMRC: to view location of your default
==in Visual Mode to fix line indent.
:resize 60to resize windows horizontally or
:vertical resize 60for vertical resizing. Also signed values can be used like +5, -2.
:centerto align text. Assuming width of document is
textwidth(default is 80). You can also specify arguments for e.g
:center 100will move the start of line to 100th column.
:buffersin command mode. You can switch to a buffer by providing the buffer name,
:buffer <TAB>to see all buffers.
:verb map <key>to check which key is mapped to what operation. Useful when debugging your mappings and differentiating them from that of a plugin.
Read help for checking key notations
wildignoresetting to exclude searching for files and directories according to your project. For e.g for python projects this could look like
:h 'wildignore']. Another handy trick is to exclude media files from appearing in search by excluding them as well.
:syntaxwill output all highlight groups for syntax highlighting of the current open file. It can come handy when you are writing your own colorscheme.
scrollbind. Pick one window then
:set scb, pick another window
:set scbfor disabling use
:set spell) enabled use
zgto exclude certain words from being reported as misspelled. This adds the words to your own list of words called a spellfile. On NeoVim this fill is created automatically, although you can do it manually.
q:to open command line history or
Ctrl + fwhen already in command mode
q/to open search history, this will list all the things you searched using search mode
ito change anything and <CR> to execute again.
gd(local declaration) or
gUto make text uppercase &
:h usr_28.txtfor a quick overview)
set dictionary+=/usr/share/dict/wordsto your vimrc
:help ins-completionto see more such completions
In command mode use
:regto display contents of all these registers. Do
h registersto read manual
Qto enter into Ex mode,
visualto go back.
:termbut learning about it can be quite helpful sometimes.