website

  • alt + shift + s (Search) - (note: this is a html AccessKey)

ubuntu

  • alt + aboveTab (switch to last window)
  • ctrl + aboveTab (switch to last workspace)
    • like ^ in firefox or alt + tab in Ubuntu
  • window mgmt:
    • wmctrl -l (list)
    • wmctrl -a window-name (go to workspace and focus by window name)
      • map this to alt + shift + 1, 2, 3, etc. (after renaming the windows properly, renaming command: see below)
    • wmctrl -i -a 0x066f5d24 (go to workspace and focus by window ID)
    • wmctrl -i -a 0x066f5d24 -T "documentation" (rename)
    • wmctrl -i -a 0x0667167d -T "main-tmux" (rename)
    • more complex commands

terminal

  • ctrll (clear)

firefox

  • ctrl u (view page source code)

Page Info

  • ctrli altg (page info)
  • ctrli altm (page media)
  • ctrli altp (page permissions)
  • ctrli alts (page security, cookies, etc)

DevTools

official doc

  • ctrl + shifti (or F12) (shows the tool that was last opened)

Page Inspector

  • ctrl + shiftc (pick element mode)

Web Console

From doc:

The Web Console:

  1. Logs information associated with a web page: network requests, JavaScript, CSS, security errors and warnings as well as error, warning and informational messages explicitly logged by JavaScript code running in the page context
  2. Enables you to interact with a web page by executing JavaScript expressions in the context of the page

Shortcuts:

  • ctrl + shiftk (console) (click “…” to get side-by-side view)

JavaScript Debugger

Shortcuts

React DevTools (Addon)

  • only visible on webpages built with React
  • beside standard firefox DevTools tabs
    • React Components panel
    • React Profiler panel

vimium

  • T (switch tab)
  • click on “vimium button in firefox” → “Options” (to see custom maps)
  • yt (duplicate tab)
  • gi (jump into the first search box (must be in the view, does not work if you have to scroll the box into the view!))
  • gs (view source)
  • HL (tabs)
  • JK (history)

Textmarker

  • Notes:
    • Warning: the “x” button deletes the note, use the “-“ button to hide
  • sidebar contains useful buttons, eg.
    • jump from one highlight to the next/previous
    • Notes: if a highlight has a Note attached to it, there is a small white box beside it in the “Marks and Notes” list
      • helps to quickly find all existing Notes (without clicking through all of them)

cpp

godbolt

  • f1 (command palette)
  • ctrlx (cut line)
  • ctrld (duplicate line)

markdown

  • alti (next # )
  • alto
  • :LspStop 1 (tailwindcss) (because the treesitter markdown parser is sufficient)
  • altf (insert arrow symbol)

vim-markdown

  • ge (format a table)
    • when the table contains code with a pipe symbol “|” this won’t work, but you can use the following workaround:
      • first escape all pipe symbols with a backslash \, but not the |-symbols of the table
      • format the table with ge
      • manually remove all \ again
    • this works only if all rows of the table start with a “|“-symbol
      • you can run something like :%s/\(^`.*`\s|\)/| \1/g to reformat all tables in your markdown files, so that ge works

LaTex

  • math mode
    • altb
    • altu
    • altt ($[ \text{Let}\ x=\text{number of cats}. ]$)

nvim

Debugging

  • print(lua-variable)
  • print'some-string'

Useful Help Pages

Variables

  • :echo $SOME_ENV_VAR (print the value of SOME_ENV_VAR)
  • :echo g:someGlobalVar (print the value of vim.g.someGlobalVar)
  • :echo b:someBufferVar (print the value of vim.b.someBufferVar)
    • eg. :echo b:AutoPairs shows the list of all currently set AutoPairs for the current buffer
  • :set someOption? (print the value of someOption)
  • :lua =table (print a lua table)

nvim Plugins

Lazy

  • plugin spec: list of properties when adding plugins to init.lua
  • dev.to
    • restore specific plugin to previous state/version
    • revert all plugins to previous state/version
  • :Lazy (must update regularly)
  • C (check if a tag exists, after changing tag = or version = in init.lua)
  • :checkhealth (debug broken plugins, shows a log)
    • hint: use :set ft=markdown for syntax highlighting
    • :checkhealth somePluginName

LSP, Mason

  • space ca (apply code fix)
  • :Mason (manage all LSPs, DAPs, Linter, Formatter)
  • install new language servers via :LspInstall <tab>
  • :LspInfo
    • (Note: die “installierten” server sind in der Zeile ganz unten in der Ansicht! Die server, die oben in der Liste sind, sind die “aktiven” für aktuelle buffer!)
  • :LspStop serverName
    • eg. to stop tailwindcss server for markdown files (→ markdown)

lsp_signature.nvim

  • shows the function signature in a floating window while typing
  • highlights the current parameter in the signature
  • altp (focus the floating window, put the cursor in the floating window)
    • altu, altd (while in the floating window: move cursor up/down)

Diagnostics

  • definition in neovim doc
    • “Nvim provides a framework for displaying errors or warnings from external tools, otherwise known as “diagnostics”. These diagnostics can come from a variety of sources, such as linters or LSP servers. The diagnostic framework is an extension to existing error handling functionality such as the quickfix list.”
  • leadere (open floating diagnostic message, useful if you cannot read the inline message)

Formatter

  • list
    • markdown: prettier.formatfile
    • lua: :Format (LSP format buffer)
    • cpp: :ClangFormat (rhysd/vim-clang-format)
  • TODO: install conform.nvim
  • leaderjkey-for-language
  • available formatters:
    • :ClangFormat
    • coc-prettier, github
      • typical workflow:
        • To install prettier in your project and pin its version as recommended, run: npm install prettier -D --save-exact
        • Then, create an empty config file to let editors and other tools know you are using Prettier: node --eval "fs.writeFileSync('.prettierrc','{}\n')"
        • Next, create a .prettierignore file to let the Prettier CLI and editors know which files to not format. Here’s an example: node --eval "fs.writeFileSync('.prettierignore','# Ignore artifacts:\nbuild\ncoverage\n')"
        • Now, format all files with Prettier: npx prettier . --write
          • prettier --write . is great for formatting everything, but for a big project it might take a little while. You may run prettier --write app/ to format a certain directory, or prettier --write app/components/Button.js to format a certain file.
    • :Format, alias for vim.lsp.buf.format() (defined in init.lua)

clang, clangd

  • clang is the compiler
  • clangd is the language server

clang

compile commands json

  • From :LspInfo → press tab:
    • If compile_commands.json lives in a build directory, you should symlink it to the root of your source tree. ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/

compile flags txt

  • doc
  • run :LspRestart to reload
  • for simple projects (eg. compile one file only):
    • create a compile_flags.txt
      • in the folder where the source code is
      • eg. with the content -std=c++20

Example compile_flags.txt:

-nostdlibinc
-I/home/bra-ket/osbook/devenv/x86_64-elf/include
-I/home/bra-ket/osbook/devenv/x86_64-elf/include/c++/v1
-I.
-D__ELF__
-D_LIBCPP_HAS_NO_THREADS
-O2
-Wall
-g
--target=x86_64-elf
-fno-exceptions
-ffreestanding
-fno-rtti
-std=c++2a

.clangd (project configuration file, yaml)

  • e.g. to suppress In included file: main file cannot be included recursively when building a preamble add
Diagnostics:
  Suppress: 'pp_including_mainfile_in_preamble'

to .clangd

autocomplete, completion

  • see also Help Code, Doc
  • 3 popup/drop-down Arten:
    • vim builtin completion (sieht so aus wie completionVorschlag1)
    • coc.nvim (sieht so aus wie completionVorschlag1 [A])
    • nvim-cmp (sieht so aus wie completionVorschlag1 Variable)
  • ctrl y (confirm + replace)
  • ctrl e (discard + do not do anything)
    • helpful eg. if two conflicting completion popups appear at the same time, ctrl e will switch between these

vim builtin completion

  • ctrl n (next suggestion)
  • ctrl p (previous suggestion)
  • ctrl x followed by ctrl f (Path completion)
    • select with ctrl n then press ctrl x followed by ctrl f again to select the next subfolder etc.

nvim-cmp, LuaSnip, friendly-snippets

  • das completion popup mit den Kategorien (Variable, Function, Keyword, usw) in der rechten Spalte (zB completionVorschlag1 Variable, completionVorschlag2 Keyword, completionVorschlag2 Function, usw) wird von nvim-cmp erzeugt
  • servers must be added to the LSP server list local servers = {} in init.lua, otherwise nvim-cmp will not autocomplete
  • luasnip (snippet engine)
    • :LuaSnipListAvailable
    • nvim-cmp requires a snippet engine
    • tab, shifttab
      • select item in drop-down
        • if the item is a function a snippet is inserted
      • edit next/previous function parameter in the function snippet
    • luasnip config: Example-mappings#luasnip
    • TODO:
  • friendly-snippets (snippet collection)
  • nvim-cmp steuert scrolling im “documentation preview” popup
    • press ctrl f to scroll down
    • alle key mappings in .config/nvim/init.lua bei cmp.setup { ..., mapping = ... }
    • problem: you cannot jump into the documentation preview window in nvim-cmp (which is important to open links in the documentation preview window, eg. MDN links for JavaScript)
      • solution: instead, you can first autocomplete an expression and then press ctrl k or shift k while the cursor is on the completed expression

friendly-snippets

important: Each language has its own Wiki page where you can find all keymaps to trigger the snippets.

Other Tricks:

How to type the following code?:

<div className='wrapper'>
  |
</div>
  • steps:
    • press j and select the “jsx element” snippet
    • write div into the first jsx tag and press Esc (or jj)
      • this will write another div into the second jsx tag while the cursor remains in its current position
    • press a and write classN, then press tab to select className?~ Field, press Enter on className?~ Field
      • this will put a className='|' attribute into the first jsx tag with the cursor positioned in between the single quotes (where the vertical bar | is)
    • write wrapper
    • after typing the last r of wrapper press ctrlo and then j
      • this will place the cursor in the middle line between the first and second jsx tag (where the vertical bar | is) in insert mode
      • you can press ctrloj even after just typing wra, pressing tab and selecting wrapper and before pressing Enter on wrapper in the popup (ie. once you select wrapper, the completed word wrapper will not disappear when you press ctrloj)

coc.nvim

  • das completion popup mit den eckigen Klammer Symbolen in der rechten Spalte (zB completionVorschlag1 [A], completionVorschlag2 [B], usw) wird von coc.nvim erzeugt, wobei jedes eckige Klammer Symbol für jeweils eine “source” steht, die in :CocList → “sources” registriert wurde
    • am besten alle “sources” deregistrieren (über :CocList → “sources”), weil sonst der nvim-cmp popup und der coc.nvim popup manchmal gleichzeitig erscheinen
    • wobei das source namens File nützlich ist (zeigt die files in cwd, wenn man ./ typet)
  • :CocList (select “sources” to configure which sources are used for autocompletion)
  • :CocConfig (opens coc-settings.json where you can configure Coc, eg. you can turn off Coc’s autocompletion by adding "suggest.autoTrigger": "none" to coc-settings.json)

nvim-tree

  • P (parent directory)
    • Ptab (collapse parent)
  • f somepattern (filter the tree)
  • - (show more (show parent folder))
  • ctrl] (show less (only show the folder on which the cursor is placed, ie. this works only if the cursor is placed on a folder))
  • c then p (duplicate file, automatically shows “rename” where you have to choose a new name)
  • for Firefox-Bookmarks-like behavior use
    • init.lua: on_attach keymap: bind ctrle to api.tree.toggle
    • keymaps.lua: normal keymap: bind ctrle to :NvimTreeFocus
  • alth, altl (focus/unfocus nvim-tree, when nvim-tree open)
  • a then put a “/” at the end of the written name (create dir)
  • J (jump to last item in folder)
  • K (jump to first item in folder)
  • i (show gitignored folders and files)
  • U (show hidden folders and files)
  • q (quit)
  • statt netrw
  • / (search)
  • ctrld (collapse)
  • gy (get absolute path)
  • Y (get relative path)

toggleterm (for lazygit integration in nvim)

  • enter terminal mode: press i
  • scroll (= enter normal mode)
    • ctrl\ ctrln to exit terminal mode, then you can use vim motions to move around
    • scroll with mouse first and then you can use pageUp/pageDown
    • press i to enter terminal mode again
  • written in lua
  • better than floaterm (written in vimscript)
  • 1ctrl\, 2ctrl\, 7ctrl\, etc. to create and access terminals
    • the prefixed number is the number of the terminal instance
    • pressing a non-existent number will create a new terminal

git

gitsigns

This plugin is only active in git-tracked folders. Ie. :map (and, therefore, space sk) will not show any keymaps related to gitsigns in non-git-tracked folders.

  • alt , (next hunk)
  • alt . (prev hunk)
  • space h b (blame line)
    • um schnell herauszufinden in welchem commit die line geaddet wurde
    • press the keymap twice to jump into the preview window (useful if you want to copy the commit hash in the preview window in order to see the whole commit)
  • diff
    • space h d (diff zu letztem commit)
    • space h D (diff zu vorletztem commit)
    • better use fugitive: space g f (see fugitive)

lazygit

  • meaning of keymaps (official doc)
  • altenter (when writing a commit message: starts a new line)
  • when lazygit spins up the external hard drive so that lazygit lags, open nvim ~/.config/lazygit/state.yml and run :g/^-\ \/media/d to remove all “recent repo” paths to a git repo on the external hard drive
  • start lazygit
    • space gg (for normal repos)
    • space gd (for dotfiles repo)
  • each panel has its own help menu!
  • commands that work in all panels
    • R (Refresh the git state (i.e. run git status, git branch, etc in background to update the contents of panels). This does not run git fetch.)
      • does not work in the “branches” panel because “rename branch” is also mapped to R
    • W (groß W, diff menu)
    • ctrl r (switch repo)
      • does not work when a commit is selected during cherry-picking (see commands under “commits” panel)
    • @ (focus command log)
    • x (help) (ins commit panel und auf x drücken, zeigt zB amend, reset, etc.)
    • H, L (scroll left, right)
      • praktisch um kleine panels zu lesen, e.g. “commit” panel
    • h, l
      • switch between the 5 panels (or 12345)
    • \[, \]
      • tabs sind getrennt durch “-“
      • zB “Commit” - “Reflog” sind 2 tabs
    • + (rotate through views, zoom-out - not necessary then)
    • esc (go back, Achtung: q is for exit lazygit!)
    • esc (go back to commit list after seeing a commit’s files)
    • pageup/pagedown to scroll the main panel
    • ctrl -/+ (zoom out/in, very useful to view the full main panel)
      • better: press enter on the file in the “files” panel, then press + to rotate to the view where the file spans the full width of the screen
  • in “files” panel
    • d (git checkout, to discard changes made to a file)
    • A (amend)
      • erst space und dann A
  • in “commits” panel
    • ctrls (show commits for a specific file only)
      • when you want to see the commits of a deleted file you have to checkout one of the commits before the commit where the file was deleted, then ctrls will work for this file (when you are done, you can checkout master in the “branches” panel to get back the latest commits)
    • / (search commits, Warning: if a commit message has more than one line the search will only search in the first line of the commit message, doc)
    • + (view awesome commit graph, or just to make the commit messages more readable)
    • ctrlo (copy commit SHA to clipboard; useful eg. when writing commit messages that refer to other commits)
    • um mehr vom file zu sehen:
      • im “Commits” panel den commit fokussieren (aber nicht enter drücken) und dann mehrmals \} drücken, sodass am Ende der ganze file sichtbar ist
      • better: press enter on the file in the “files” panel, then press + to rotate to the view where the file spans the full width of the screen
    • reword commit messages
      • R (change multiline commit message)
      • r (change commit message)
    • cherry-pick
      • c (select cherry-pick)
      • v (apply cherry-pick to the current branch)
      • ctrl r (unselect cherry-pick)
  • in “stash” panel (first you have to stash changes in the “files” panel)
    • space (apply)
    • g (pop)

lazygit: Git actions

  • scroll
    • H / L (left/right) (useful when committing hunks with the “stage individual hunks” function)
  • add
    • a (git add all)
    • space (git add file, press again to undo)
  • commit
    • c
  • push
    • P (UPPERcase!)
  • pull
    • p (lowercase!)

fugitive

  • for normal git commands use exclamation mark “:!git ...
  • :G (former “Gstatus”, press g? to see what you can do)
  • :G <tab><tab> to see available commands
  • :G log
  • :G shortlog
  • :Gdiffsplit HEAD~1 (horizontal view)
  • :Gvdiffsplit HEAD~1 (vertical view)
    • space g f
    • in the right buffer select the changes you want to add with v and then press dp (so that the changes are added to the left buffer), then :write the left buffer to stage (aka git add) these changes, see :h :Gdiffsplit
  • :Gread % (git checkout) (use u to undo/go back)

GV

  • öffnet sich in neuem Tab, d.h. “H”, “L” um mit aktuellem file zu vergleichen
  • space gc (only commits of current file)
  • space ga (all commits)
  • q (quit)

telescope

  • ' (prefix ' to the search string to get an exact match instead of a fuzzy match, eg. useful when searching keymaps by writing the key combination)
  • :h (telescope.mappings)
  • ctrl/ (in insert mode), ? (in normal mode) (show shortcuts)
  • spacespace (recent files)
    • based on :oldfiles (:h :o)
      • eg. you can filter the :oldfiles list using :filter pattern o (where :o is the short version of :oldfiles, see :h :o)
    • to remove entries in :oldfiles edit the “ShaDa” file using nvim nvim .local/state/nvim/shada/main.shada (see vi.stackexchange)
      • eg. you can install michaeljsmith/vim-indent-object and then use :g/pattern/norm dai
      • note: nvim has a different :oldfiles system than vim (see vi.stackexchange)
      • useful if you accidentally put some files in the :oldfiles list that are on an external hard drive (the hard drive has to spin up each time you press this telescope shortcut while the frozen telescope window is blocking nvim)
        • in this case you can run :g/\/media\/bra-ket\/INTENSO\//norm dai to clear the :oldfiles list from all entries that are causing this behavior
  • ignoring files (comment):
    • put them in .ignore
    • use the file_ignore_patterns telescope option (:h telescope.defaults.file_ignore_patterns)
    • use .gitignore
  • ctrlt (open file in new tab)
  • ctrl-/+ (see more of the preview pane/results pane)
  • ctrlu, ctrld (scroll preview up/down)
  • spacesk (search keymaps of active plugins, ie keymaps of inactive plugins are not shown)
  • spacesa (search autocommands, my own custom autocommands have a ph_ prefix in their augroup so that I can find them more easily in telescope or via :autocmd ph_<tab>)
    • what is augroup?
    • better: use :autocmd ph_<tab> to find autocommands and their doc (specified in the desc = "..." field of nvim_create_autocmd)
  • space? (recently opened)
  • space/ (current buffer find)

treesitter

(note: treesitter highlighting is distinct from the LSP-based “semantic highlighting”)

  • :set ft=markdown (enable syntax highlighting for unwritten buffer, ie a “No name” buffer)
  • from supported-languages
    • to support a specific feature for a specific language requires both
      • a parser for that language and
      • an appropriate language-specific query file for that feature
    • :TSInstall parserName (install a specific parser)
      • in use: markdown, markdown_inline
    • :TSInstallInfo (list all installed parsers)
    • :TSModuleInfo (colorful overview of installed features :h :TSModuleInfo)
    • :TSUninstall parserName
  • v multiple times (select nodes, von innen nach außen)
    • altv (decrement selection)
    • shiftv (“select line” works as usual)
  • press ] (next) or [ (previous) to see keybindings
    • jumps to
      • start of next function/class
      • end of next function/class

treesitter-textobjects

  • an external plugin for the main treesitter plugin
  • if and af (inner/outer function)
    • eg. cif to delete the inner part of a function

Aerial

  • ToC window mode:
    • space bb
    • space bt (Telescope Search)
      • faster than “bb” for jumping to sections
    • also try: ctrln, ctrlp (next / previous section)
  • sidebar mode:
    • g?
    • q
    • zM (collapse all)
    • ctrlb (fast markdown section select)

Vista (Aerial ist besser!)

  • Vista: in “:h Vista”: tag: vista-key-mappings
  • q (quit)
  • p (preview)

vim illuminate

auto-session

  • while in the session-lens telescope picker:
    • c-s restores the previously opened session. This can give you a nice flow if you’re constantly switching between two projects.
    • c-d will delete the currently highlighted session. This makes it easy to keep the session list clean.
  • space cs (save session)

nvim Profiling

reddit.com

Try run nvim with nvim -u NONE. Is it still slow?

Try profiling when inside that file.

:profile start profile.log
:profile func *
:profile file *.

Now start doing what is slow

:profile pause.

Quit vim and open profile.log.

At the end you should see sum of functions exec times and count of usage. Should point you.

bot summon :help profile

Finding Keymaps

  • :nmap <some-key> to list all bindings with <some-key>
  • space sk (show keybindings in Telescope)

Understanding Code

Documentation

  • LSP Documentation:
    • shift k (hover doc, for objects: press when cursor is on object)
      • press 2x to jump into def window
      • press q to jump out
    • ctrl k (function signature doc, for functions: press when cursor inside function brackets)
      • press 2x to jump into def window
      • press q to jump out
  • nvim-cmp documentation preview window
    • problem: you cannot jump into the documentation preview window in nvim-cmp (which is important to open links in the documentation preview window, eg. MDN links for JavaScript)
      • solution: instead, you can first autocomplete an expression and then press ctrl k or shift k while the cursor is on the completed expression

Definitions

  • LSP Definitions:
    • gd (go to def)
    • gr (go to references)

Search for Words

  • Search through content of ONE file:
    • (symbols: classes, properties, methods)
      • space ds (native lsp)
      • space bb (aerial)
        • space bm (collapse all in aerial)
      • space bt (aerial in telescope)
    • gr (e.g. cycle through all occurrences of a variable in the file)
  • Search through content of ALL files:
    • space sw (search word under cursor; gives the same results as space sg)
    • space sg (search by grep all files in cwd)

vim

  • ; (undo repeat)
  • , (repeat)
  • ga (show ascii code of letter under cursor)

custom

  • fc (`keymaps.lua`)
  • fi (`init.lua`)
  • fp (`plugins/init.lua`)

motion (in a line)

  • fletter,,,, (jump to letter, press , repeatedly to jump to the next letter)
  • B (beginning of previous WORD, faster than b)
  • E (end of WORD, faster than e)
  • gE (end of previous WORD, be does not work if cursor currently in middle of a word)
  • ge (end of previous word, be does not work if cursor currently in middle of a word)
  • Ea (start writing at end of WORD)
  • ea (start writing at end of word)

motion

  • search
    • shiftN (instead of ? to search backwards)
  • g_ (end of line, last non-blank character)
  • :changes related motions (jumping between change locations)
    • g; and g, (jump to previous/next change location)
  • blocks
    • [% (jump to beginning of block) → alt h
    • ]% (jump to end of block) → alt l
      • sometimes when there are multiple brackets and parentheses [{ or [( can be faster than [%
      • see vi.stackexchange
    • % (jump out of parenthesized block to 1st parenthesis)
    • %% (jump out of parenthesized block to 2nd parenthesis)
  • backtick (list possible jumps and marks)
    • backtick . (jump to last change in current buffer)
    • m + markLetter (set jump mark)
    • backtick + markLetter (jump to mark)
  • move
    • ), (
    • * fwd, # bwd
  • markdown sections
    • ctrln, ctrlp (next / previous section)

edit

  • ctrlr % (in insert mode: insert current file name)
  • registers
    • " (show all registers)
    • "ry (yank text to register "r)
    • "rp (paste text from register "r)
    • record arbitrary normal mode commands:
      • qa5jq (q: start recording into register “a”, 5j: record motion “5j”, q: stop recording)
        • "a (to use the recorded command 5j in normal mode)
  • delete
    • D (like d$)
    • ciw (statt diwa, diwi)
    • de (statt dw)
    • 0d$ (clear line without deleting it)
  • find and replace
    • :%s///gc (find and replace in buffer; g for all occurrences; c for confirm)
    • :s///gc (find and replace in one line; g for all occurrences; c for confirm)
  • replace one word:
    • cw statt dwi<space>
  • replace more than one word:
    • vt letter, vf letter (if you need to paste) statt ve
    • ct letter (change till letter)
    • dt letter (delete till letter)
    • df letter (delete till and including letter)
  • f (“find” in motions)
  • t (“till” in motions)
  • rx (replace character under cursor with x, where x can be any letter)
    • less useful:
      • 3rx (replace the two characters to the right as well)
      • Rxyz Esc (replace multiple characters with xyz, where pressing Esc marks completion and backspace acts as an undo)
  • c (delete + start insert, aka “change”)
  • C (delete to EOL + start insert)
  • selection u (lowercase selection)
  • selection U (uppercase selection)
  • ~ (change case of letter under cursor)
  • A (insert at end of line, besser als $a)
  • selection c"aString" (replace selection with “aString”)
  • shiftj (append the line below)
  • text objects
    • sometimes “word” works, whereas “WORD” doesn’t and vice versa
    • W (WORD, delimited by whitespaces)
    • w (word, delimited by non-keyword characters, which are configurable)
    • iW (inner WORD)
    • iw (inner word)
    • aw (a word)
    • is, as (sentence)
    • ip, ap (paragraph)
    • overview: text-objects
    • cib (change parenthesis block)
    • vib (select parenthesis block)
    • v2ib (select nested parenthesis block)
    • ciB (change curly braces block)
    • viB (select curly braces block)
    • v2iB (select nested curly braces block)

control

  • :mes[sages] (Show all messages.)
  • ctrlo (temporary normal mode for one command)
  • :set ft? (show filetype)
    • eg. for denylist in vim-illuminate config
  • autocomplete
    • ctrly (confirm vim-complete)
    • ctrlspace (show cmp-complete)
    • enter (confirm cmp-complete)
    • ctrle (abort complete) (both cmp-complete and vim-complete)
  • buffers
    • :b partialName<tab> (open buffer)
    • :ls (list buffers)
  • sessions
    • spacefod (load default session)
    • spacefsd (save default session)
    • spacefon (load new session)
    • spacefsn (save new session)
  • tabs
    • next tab: gt or ctrlPageDown (by default in vim)
    • previous tab: gT or ctrlPageUp (by default in vim)
    • last accessed tab: gtab (by default in vim, :h ctrl-<tab>)
    • list tabs: :tabs (also shows which ones are modified, :h :tabs)
  • alth and altl (switch viewports)
    • to go to :AerialToggle and back (Avoid this! Use :AerialNavToggle (leaderbb) instead!)
    • to go to nvim-tree and back

Edit Code

  • space ca (apply code fix)
  • space rn (rename a variable)
  • _ (like ^)
    • [count]_ (1st non-blank char count-1 lines downward)
  • comments
    • repeat to uncomment
    • line: gcc (or gbc)
    • visual selection: gc (or gb)

surround

  • dst (delete surrounding tag)
  • ds) (delete surrounding parentheses)
  • ds” (delete surrounding “)
  • ds’ (delete surrounding ‘)
  • ysl” (surround letter under cursor)
  • vSo (surround letter under cursor)
  • ys3iw” (surround ohne select)
  • ys3iW” (see word vs WORD)

Troubleshooting

  • auto-session errors can often be resolved by simply deleting the session (with ctrld) in the session list (press leaderss) and then restarting nvim