Skip to content

manmademagic/vim-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Overview

These are just some personal notes on various functionality across Vim-like editors.

Writing these out is mostly for my own sake, but it helps me to remember by:

  1. researching to confirm how things work
  2. testing to get a feel of how they work
  3. acting as a future reference for when I inevitably forget

General Vim Things

Insert Mode

Ctrl Commands

Useful Ctrl Commands

Command Description
<C-@> Insert previously inserted text, and stop insert
<C-a> Insert previously inserted text
<C-d> Outdent current line
<C-o> Execute a single command, then back to insert
<C-r> {register} Insert the contents of a register
<C-t> Indent current line
<C-u> Delete everything before the cursor
<C-w> Delete word before the cursor
<C-Left> Move one word left
<C-Right> Move one word right
<C-Home> Move to start of file
<C-End> Move to end of file

Not So Ctrl Useful

These are mostly handled by other keys, so you can probably remap them.

Command Description Notes
<C-e> Insert the character below the cursor Maybe useful to some, but not to me
<C-h> Same as <BS> Just use backspace...
<C-i> Same as <TAB> Just use tab...
<C-j> Same as <CR> Just use enter...
<C-m> Same as <CR> Just use enter...
<C-y> Insert the character above the cursor Maybe useful to some, but not to me

Unmapped Ctrl Commands

These are unmapped and can mostly be reused without issues. Worth noting that vim-like editors may not agree with this statement. <C-b> <C-f> <C-l> <C-s> <C-z>

Registers

:reg - Show the current states of the registers

Type Name Content
  c  ""   Yanked text
  l  "0   Yanked text
  l  "1   Some deleted text^Jcrossing multiple^Jlines^J
  c  "2   deleted text^Jcrossing multiple^Jlines
  < omitted for brevity >
  c  "-   Some
  c  ":   :reg

Register Types

Selection Type Description
v c - characterwise Inside/across lines
V l - linewise Across entire lines
<C-v> b - blockwise-visual Rectangular blocks of characters

Register Names

Name Register Description
"" Unnamed register Stores yanked, changed, and deleted text
"0 "yank" register Stores most recently yanked text
"1 - "9 Numbered registers Stores 9 most recently deletions longer than one line
"- Small delete register Stores the most recent deletions shorter than one line
"a - "z Named registers Explicitly defined registers to use for whatever you like
". Read-only registers Last inserted line
": Read-only registers Last executed command
"% Read-only registers Name of the current file
"# Alternate file register Name of the last file you opened
"* and "+ Selection registers System clipboard1
"_ Black hole register Used to send text to the void
"/ Last search pattern register self explanatory

Usage examples:

  • "*yy - Yank line to system clipboard
  • "0p | Ctrl-R 0 - Paste from the yanked register
  • "_db - Delete backwards, but don't store the text

The numbered ("1-"9) registers will automatically increment when using . to repeat an action. So you can delete lines in multiple places, then use the actions "1P . . . to paste them in order.

The system clipboard can be changed to use the unnamed register by running :set clipboard==unnamed or lua vim.opt.clipboard = 'unnamed'.


VSCode Vim

vim.mode != 'Insert'

Neovim in Windows Terminal

Some combination of Ctrl keys don't work as expected when using nvim via windows terminal. To fix this, you can modify the terminal settings.json file to handle these combos properly.

The current schema will complain that keys isn't a valid option, but saving then opening terminal will automatically split into actions & keybindings.

"actions":
[
  {
    "command":
    {
      "action": "sendInput",
      "input": "\u001b[32;5u" // Send Space [32] and with Ctrl modifier [5u]
    },
    "keys": "ctrl+space"
  },
  {
    "command":
    {
      "action": "sendInput",
      "input": "\u001b[105;5u" // Send i [105] and with Ctrl modifier [5u]
    },
    "keys": "ctrl+i"
  },
]

Footnotes

  1. Very simplified explanation... The usage of * or + may differ in X11

About

A pretty scrappy list of tips and tricks for vim for myself

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors