172 lines
7.2 KiB
Text
172 lines
7.2 KiB
Text
NOTES ON NEOVIM AND MY PERSONAL NEOVIM WORKFLOW
|
|
|
|
FOR OFFICIAL DOCUMENTATION OF NEOVIM, PLEASE VISIT THEIR GITHUB: https://github.com/neovim/neovim
|
|
|
|
I have created this small txt file to document my basic neoneovim work flow
|
|
It is combined with notes about my espanso keybindings, which are meant to aid in the workflow
|
|
Keep in mind these are specific to my neovim setup and will definitely not work in all neovim setups
|
|
|
|
-- Standard keybindings (all neovim)
|
|
|
|
NORMAL MODE
|
|
|
|
h - go one character left (prepend with a number to go that many characters)
|
|
j - go one character down (prepend with a number to go that many characters)
|
|
k - go one character up (prepend with a number to go that many characters)
|
|
l - go one character right (prepend with a number to go that many characters)
|
|
w - go to the right to the beginning of the next word (delimited by spaces)
|
|
b or shift b - go to the left to the beginning of the last word (delimited by spaces)
|
|
e or shift e - go to the right to the ending of the next word (delimited by spaces)
|
|
0 - go to beginning of line (prepend with a number to go that many characters)
|
|
$ - go to the end of the line (prepend with a number to go that many characters)
|
|
gg - go to top of the page
|
|
shift + g - go to the bottom of the page
|
|
ctrl u -page up
|
|
ctrl d - page down
|
|
/ - forwards slash searches foor the word/term you wish to jump to, just press enter once it is highlighted
|
|
:w - writes (my nneovim setup as autosave, but it's still a good feature to have)
|
|
:q - quits neovim (first neovim command to learn)
|
|
u - undoes last change (can be used with prepended numbers depending on how many steps you want to undo)
|
|
ctrl + r - reverts changes over after unintentional undoing (undoes the last undo commands, also can be prepended by a number)
|
|
|
|
d - beginning d keybinding, can be combined with many of the above commands (it cuts, so you can paste it using p keybinding)
|
|
(can be prepended by a number, and multiples the amount of words/lines is deleted/cut)
|
|
dh - delete word one back (equivalent to db)
|
|
dj - delete one line down
|
|
dk - delete one line up
|
|
dl - delete word one forward (equivlanet to dw)
|
|
dd - delete current line
|
|
d0 - delete from current cursor position to the beginning of the line
|
|
d$ - delete from the current cursor position to the end of the line
|
|
dgg - delete from the current cursor position to the beginning of the document
|
|
dG - delete from the current position to the end of the document
|
|
dw - delete word on current position
|
|
de - delete current cursor position to the end of the word
|
|
db - delete current cursor position to the beginning of the word
|
|
x - delete character under current cursor position
|
|
|
|
interesting use case:
|
|
di( - will delete everything encapsulated in the following parenthesis
|
|
di{ - will delete everything encapsulated in the following curly brackets
|
|
di[ - will delte everything encapsulated in the following square brackets
|
|
|
|
y - beginning y keybinding, yanks or copies character or word for pasting elsewhere using the p keybinding
|
|
(can be prepended by a number, and multiples the amount of words/lines to be copied)
|
|
yh - copies one word back (equivalent to yb)
|
|
yj - copies one line down
|
|
yk - copies one line up
|
|
yl - copies one word forward (equivlanet to ye)
|
|
ye - copies one word forward
|
|
yb - copies one word back
|
|
yy - copies entire line
|
|
yw - copies entire word
|
|
y0 - copies from current cursor position to beginning of line
|
|
y$ - copies from current cursor position to end of line
|
|
yG - copies from current cursor position to the end of document
|
|
ygg - copies from current cursor position to the beginning of document
|
|
|
|
FROM NORMAL MODE, ENTERING OTHER MODES
|
|
i - enter INSERT mode at the current cursor position
|
|
a - enter INSERT mode at the following cursor position (appending)
|
|
shift + i - enter INSERT mode at the beginning of the line
|
|
shift + a - enter INSERT mode at the end of the line
|
|
v - enter VISUAL mode
|
|
shift + v enter VISUAL mode and select the current line
|
|
shift + r enter REPLACE mode (think of this as INSERT in windows/mac, simply replaces all text beneath cursor while in this mode)
|
|
ctrl + v - enter VISUAL BLOCK MODE
|
|
|
|
NO MATTER WHAT MODE YOU'RE IN, you can always:
|
|
<ESC> to return to NORMAL MODE
|
|
|
|
INSERT MODE
|
|
|
|
tab - configured for four spaces in my case
|
|
|
|
VISUAL MODE
|
|
|
|
h,j,k,l,g,shift+g,0,$ all apply, it simply highlights them
|
|
and you can use standard and custom commands here that would normally apply in NORMAL mode
|
|
|
|
CTRL + V ENTERS VISUAL BLOCK MODE
|
|
I only really use this for muliple commenting out of lines
|
|
(ctrl + v + j or k and then ctrl+c to comment out code)
|
|
|
|
--Custom Keybindings
|
|
|
|
NORMAL MODE
|
|
|
|
nf Simply typing this in NORMAL MODE will invoke Neoformat, simply hit enter afterwards
|
|
CTRL + p or fzf Simply typing this in NORMAL MODE will invoke FuzzyFileFinder, simply hit enter afterwards
|
|
rg Simply typing this in NORMAL MODE will invoke RipGrep, simply hit enter afterwards
|
|
|
|
CTRL + x removes highlighting from previous search results
|
|
|
|
CTRL + c Comment out line (use in conjunction with CTRL + V for multiple lines)
|
|
|
|
CTRL + j/k Enter Multi-Cursor (red cursor is NORMAL MODE< yellow cursor is INSERT MODE) (hit <ESC> to return to NORMAL MODE - might require hitting <ESC> multiple times)
|
|
|
|
SHIFT + m Open up Markdown Preview for .md files (mainly used for README.md)
|
|
|
|
CTRL + p Open fuzzy file finder like search application
|
|
|
|
:Neoformat Formats most code options (don't use with .c or .cpp files as there is another application i use for that)
|
|
|
|
cp alias for using ClangFormat C/C++ Formatter
|
|
|
|
CTRL + b : Open Nneovim Tree
|
|
in Nneovim Tree there are specific keybindings (most standard neovim keybindings work here as well):
|
|
a - creates new file (keep adding slashes to create directories or don't for regular files)
|
|
d - deletes file (hit y when prompted)
|
|
r - renames file (enter new name and hit enter)
|
|
|
|
/ search for a word in whichever document you have Open
|
|
|
|
CTRL + v open file in Nneovim Tree in new vertical workspace
|
|
(if more than 2 are open, Nneovim will ask which one you wish to open it next to, A or B or C etc)
|
|
|
|
CTRL + h Navigate to one vertical window to the left
|
|
CTRL + l Navigate to one vertical window to the right
|
|
|
|
CTRL + e to adjust window width (h and l will adjust width, just hit enter afterwards to adjust, opening and closing nneovim tree readjusts back to defaults)
|
|
|
|
CTRL + t open new tab
|
|
|
|
ALT + <right arrow> or <tab> goes to next tab
|
|
|
|
ALT + <left arrow> or SHIFT + <tab> goes to previous tab
|
|
|
|
SHIFT + S Aliased to global search and replace
|
|
|
|
SHIFT + T Runs jester unit tester on appropriate .test.js files
|
|
|
|
F11 Toggle Spellchecker
|
|
|
|
-- INSERT MODE
|
|
|
|
ii - equivaent to <ESC> key (return to normal mode from insert mode)
|
|
|
|
-- ESPANSO BASED commands
|
|
NOTE: Espanso can be used in conjunction for some powerful aliases in neovim (as well as other applications)
|
|
FURTHER NOTATION: Please note that espanso is capabale of a lot more than is featured here and I highly recommend coming up with further expamples as it has the potential to greatly increase workflow speed
|
|
SEE: https://espanso.org/
|
|
|
|
Here are just some of my favorite expanded texts
|
|
In NeoVim's INSERT MODE, simply type
|
|
|
|
:command-prepended-by-colon - expands to this
|
|
|
|
:cll - console.log()
|
|
:cle - console.error()
|
|
:clt - console.table()
|
|
:func - function () {}
|
|
:def - def():
|
|
:fn - pub fn () {}
|
|
:for - for (;;) {}
|
|
:while - while () {}
|
|
:do - do {} while ()
|
|
:if - if () {}
|
|
:elif - else if () {}
|
|
:else - else {}
|
|
:try - try {} catch(error) {}
|
|
:inc - #include
|
|
:$ - `${}`
|