wiki-js/Linux/vim.md

3.4 KiB

title, description, published, date, tags, editor, dateCreated
title description published date tags editor dateCreated
Vim true 2025-10-13T15:25:45.874Z markdown 2025-10-11T16:38:44.398Z

Vim

Insert

Command Description
i Insert before cursor
I Insert at start of line
a Insert after cursor
A Insert at end of line
o New line below
O New line above
<Esc> Back to Normal mode

Navigation

Command Description
h / l Move left / right
j / k Move down / up
e / b Next / previous word
0 / $ Start / end of line
gg / G Start / end of file
Ctrl+d / Ctrl+u Half-page down / up
Ctrl+f / Ctrl+b Full-page down / up
:n Go to line n

Edit

Command Description
x Delete character
r Replace character
viw Select current word
dd Delete (cut) line
dw Delete (cut) word
x Delete (cut) character under cursor
yy Yank (copy) line
p Paste below
P Paste above
u Undo
:m+1 Move current line up one line
Ctrl+r Redo
. Repeat last change
"+y Copy to system clipboard
"+p Paste from system clipboard

Search and Replace

Command Description
/pattern Search forward
?pattern Search backward
n / N Next / previous result
:%s/old/new/g Replace all in file
* Seach for current word

Indent, Format, Repeat

Command Description
>> / << Indent / unindent line
= Auto-indent selection
J Join line below
. Repeat last command
:set number Show line numbers
:noh Clear search highlight
:s/old/new/g Replace all in current line
:%s/old/new/gc Confirm each replacement

Visual Mode

Command Description
v Start character selection
V Line selection
Ctrl+v Block selection
y Yank (copy)
d Delete
p Paste over selection

File Navigation

Command Description
Next editor :bn
Previous editor :bp
Close current :bd
List buffers :ls
Jump to buffer N :bN

VS Code Integrations

Action Shortcut
Open command palette :action ShowCommands or Ctrl+Shift+P
Open file Ctrl+P
Toggle terminal `Ctrl+``
Split editor :vsplit or Ctrl+\
Switch editor group Ctrl+w w
Save :w or Ctrl+s
Quit :q
Save & Quit :wq

settings.json

    "vim.useSystemClipboard": true,
    "vim.hlsearch": true,
    "vim.ignorecase": true,
    "vim.smartcase": true,
    "vim.cursorStylePerMode.insert": "line",
    "vim.insertModeKeyBindings": [],
    "vim.leader": " ",
    "vim.useCtrlKeys": true,
    "vim.handleKeys": {
    "<C-p>": false,
    "<C-n>": false,
    "<C-t>": false,
    "<C-Tab>": false
    },
    "vim.normalModeKeyBindingsNonRecursive": [
        // Easier access to { and }
        { "before": ["å"], "after": ["{"] },
        { "before": ["¨"], "after": ["}"] },

        // Easier access to [ and ]
        { "before": ["ö"], "after": ["["] },
        { "before": ["ä"], "after": ["]"] },

        { "before": ["§"], "after": ["$"] },
        { "before": ["<C-s>"], "after": ["<Esc>"] }

    ]