11 KiB
11 KiB
Cheatsheet pwnvim Hotkeys Reference
This is a combination of built-in universal keys and things that are specific to my config.
Misc
gxor enter to open a URL (but need gx if the URL is in a task)gfto open the file path under the cursorgvto reselect last selectiongito go back to last insertion point and insertgppaste markdown url (auto lookup the title):PasteImgwill save image to subdir if it is on clipboard- On mac, use
ctrlmodifier on screenshot likecmd-ctrl-shift-4to put screenshot on clipboard
- On mac, use
g ctrl-gshow cursor col, line, word, byte offsetsg~m switch case of movement'"go to position before last edit';go to last edited lineg;,g,go forward/backward in change listdi(,di"delete within parents/quotes. Doainstead ofifor taking out the delimiters"_cm change movement but blackhole the deletion so you can use the"register or paste- Alt: use
vmpto select that which you want to change and paste over it (or usecmd-vinstead ofp)
- Alt: use
,breduce multiple blank lines to one (or add bold in markdown files),cdchange dir to current file's path,lcdchange dir for cur buffer only to current file's path,qopen quicklist with any errorsq:opens command mode but in editor<C-f>is equivalent but launches from command mode
F2,,eShow/hide file explorerF3Fast grepF4Toggle showing invisible charactersF7Show tags or file outline drawerF8Insert current dateF9Focus mode for writingF10Quicklook preview fileF12Reset syntax parsing
Windowing
,xclose current buffer^Ws:splithoriz window split^Wv:vsplitvert window split^Wn:newhorz split with new^Wo:onlymake current window only one^Wrrotate windows^Wcclose current window pane:sbn Split the buffer window and populate new split with buffer nH,Lgoto prev/next buffer[1,]1jump to first buffer/tab (or second with 2, etc.)
Folds
zfm create fold of movement mzf/string create fold to match:rfocreate fold for range rzo,zcopen, close one foldzO,zCopen, close folds recursivelyzr,zmopen, close one fold level entire doczR,zMopen, close all folds[z,]znavigate between foldsza,<space>toggle fold under cursor
Completion
^N,^Pword completion (INSERT)^X^Lline completion (INSERT)^X^Oword completion (INSERT)^X^Uto complete :emoji: symbols (then use,eto turn it into a symbol if desired)^eto cancel autocomplete (my config)
Digraphs
^k<char1><char2>to insert digraph with two char code- ✓ = OK
- ✗ = XX
- ™ = TM
- © = Co
- → = ->
gaview code of char under cursor (note the digraph code at the end):help digraph-tableto view all
Spelling
[s,]sprev/next misspelled word[S,]Sprev/next "bad" word (skips rare words)zgadd to word listzwadd to the bad word listz=suggest words1z=auto take first suggested word^X^KAutocomplete from dictionary- Thesaurus
- https://raw.githubusercontent.com/moshahmed/vim/master/thesaurus/thesaurii.txt or http://www.gutenberg.org/files/3202/files/mthesaur.txt
- set thesaurus+=/Users/yanis/thesaurus/words.txt
^X^Tshow synonyms
Programming (many require lsp server)
,c(c space) comment, uncomment current line or selection,lsshow symbols outline,ldgoto definition,lDgoto implementation,liinfo hover,lIimplementations popup menu,lrshow references,lffixit code actions menu,ltsignature,leshow line errors,lRrename symbol,l=format current line or selection,fsdfind symbols in document,fswfind symbols in workspace,rtrun test under cursor,rTrun all tests,i1use tab for indent,i2use two spaces for indent,i4use four spaces for indent,irretab to current setting
Git
,gsbrowse git status and jump to selected file,gbbrowse git branches and switch to selected,gcbrowse git commits,ghshow current line blame,tbshow current line blame,g-reset (unstage) current hunk,g+stage current hunk,hsstage hunk,hrreset hunk,hSstage buffer,hRreset buffer,hppreview hunk,hbhunk blame,hddiff this file,hDdiff this to index]c,[cnext/prev change]n,[nnext/prev conflict:G,:GStatus- Use
ctrl + n/ctrl + pto jump between files - Press
-on a file to toggle whether it is added (git addorgit resetdepending) - Press
pon a file to walk through hunks of changes and selectively add parts of a file - Press
<enter>to view it and then:Gdiffto see changes - Press
ccto commit - Press
cato amend last commit gqto close status buffer=toggle inline diff of file under cursor (preferred)- Or
dpto invoke git diff on the file under the cursor
- Or
- Use
:Gdiff- index on left (git added or last committed), working copy on right
:diffgetwill pull changes from opposite window in allowing to undo changes- Press
sto stage a hunk - Press
uto unstage a hunk - Press
-to toggle staging of hunk - Use
]cand[cto jump between hunks
:Gcommit:GBrowseto launch current file in github in browser- "In commit messages, GitHub issues, issue URLs, and collaborators can be omni-completed (
<C-X><C-O>, see :help compl-omni). This makes inserting thoseCloses #123remarks slightly easier than copying and pasting from the browser.
- "In commit messages, GitHub issues, issue URLs, and collaborators can be omni-completed (
:Gedit :0- Open index version of current file in a tmp buffer. index file is the git added version.
:Gedit- Explore git objects to navigate commits and old versions of the tree without changing anything
- Can hit enter on parent (prev commit) or tree (state of all files at this point) and then select other files
- Get into this better with
:Gclog - When looking at a commit, hit enter on a diff line to see how things changed
- Capital
Cwill jump you from a tmp file or whatever up to related commit
:Git mergetoolload current conflicts into quickfix list (TODO: tryrion the git status screen to initiate rebase)- Navigate through the conflicted files (use the unimpaired
[qand]q) - Launch the 3-way merge tool with
:Gvdiffsplit!(the!is for 3-way andvfor vertical split)- Now put cursor in the middle window.
- Left pane, "2", is local, right pane is remote, "3". For rebase though, left seems to be master and right the local branch.
- Use
d2oord3oto pull changes from left or right for current chunk. - Navigate between chunks with
]cand[c - When a file is good, use
:Gwand move on - When finished you get to the end of the quickfix list, use
:Gto check status thenccto commit. - After commit, use
rrin the status screen or:G rebase --contineand hope you don't get a fresh set of conflicts, but if you do, repeat from the top.
- Navigate through the conflicted files (use the unimpaired
Notes
,ngspawn grammar checker,nnuse zk to add new note under $ZK_NOTEBOOK_DIR/Notes (prompt for dir),nouse zk to open note by heading or filename,ntuse zk to find notes by tag,nfuse zk to find notes,nmuse zk to make new meeting note in $ZK_NOTEBOOK_DIR/Notes/meetings,nduse zk to make new diary note in $ZK_NOTEBOOK_DIR/Calendar,nhopen hotsheet notegtturn url under cursor into titled link- in open markdown note only
,npnew peer note in same folder as this one,nlshow outbound links,nrshow reference (inbound) links,nishow info previewKover link to preview linked note
Plugin: Telescope
Fuzzy finder via Telescope
,fffuzzy search files,fgfuzzy grep files,fbfuzzy find buffer,fhfuzzy search history of open files,fqfuzzy browse quickfix,flfuzzy browse location list,fzfuzzy browse zoxide,fpfuzzy browse projects,fkfuzzy browse keymaps,fdfuzzy browse document symbols- Inside the popup window:
ctrl + pon selection to paste selection at cursorctrl + yon selection to copy selectionctrl + oon selection callopenon it- ctrl + q to put results in quick fix list
ctrl + ecreate new file in current dir or creates dir if name contains trailing slash or subdirs likedir/subdir/file
Plugin: NvimTree file explorer
<CR>,oopen a file or folder<C-e>edit the file in place, effectively replacing the tree explorer<F10>quicklook file under cursorycopy just filename to clipboardYcopy the relative path (to cwd) to clipboardOsame as (edit) with no window picker<C-]>cd in the directory under the cursor<C-v>open the file in a vertical split<C-x>open the file in a horizontal split<C-t>open the file in a new tab<,>navigate to the prev/next sibling of current file/directoryPmove cursor to the parent directory<BS>close current opened directory or parent<Tab>open the file as a preview (keeps the cursor in the tree)Itoggle visibility of files/folders hidden via git ignoreHtoggle visibility of dotfilesaadd a file; leaving a trailing/will add a directoryddelete a file (will prompt for confirmation)rrename a filexadd/remove file/directory to cut clipboardcadd/remove file/directory to copy clipboardppaste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation]e,[ego to next/prev diagnostic item]c,[cgo to next/prev git itemsopen a file with default system application or a folder with default file manager, using |system_open| optionflive filter nodes dynamically based on regex matching.Fclear live filterqclose tree windowWcollapse the whole treeEexpand the whole tree, stopping after expanding |actions.expand_all.max_folder_discovery| folders; this might hang neovim for a while if running on a big folderSprompt the user to enter a path and then expands the tree to match the path
Plugin: Unimpaired
[a,]aprev/next file if multiple specified on cli[A,]Afirst/last file if multiple specified on cli[b,]bprev/next buffer[B,]Bfirst/last buffer[l,]lprev/next location list[L,]Lfirst/last location list[q,]qprev/next quickfix errors list[Q,]Qfirst/last quickfix errors list[o,]oprev/next file in dir by alpha[<space>,]<space>add line above/below[e,]eexchange line with above/below[xm xml encode (<) movement m or VISUAL]xm xml decode (<) movement m or VISUAL[um url encode (%20) movement m or VISUAL]um url decode (%20) movement m or VISUAL[ym c encode (") movement m or VISUAL]ym c decode (") movement m or VISUAL
Plugin: Grammarous
,ngwill kick off the grammar checker]gand[gto navigate grammar issues,gfto auto fix an issue,gxto ignore an issue
Plugin: DiffView
:DiffviewOpen[xand]xto navigate conflicts,cochoose ours,ctchoose theirs,cbchoose base,cachoose alldxdelete entire conflict region,btoggle list of files<tab>and<shift>-<tab>next/prev file with conflicts