{"id":13682745,"url":"https://github.com/hackjutsu/vim-cheatsheet","last_synced_at":"2025-04-04T15:11:00.280Z","repository":{"id":45747312,"uuid":"84748647","full_name":"hackjutsu/vim-cheatsheet","owner":"hackjutsu","description":"📟 My personal vim cheatsheet","archived":false,"fork":false,"pushed_at":"2018-09-05T19:02:18.000Z","size":11,"stargazers_count":749,"open_issues_count":0,"forks_count":203,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-03-28T14:11:07.323Z","etag":null,"topics":["cheatsheet","keyboard-shortcuts","vim","vim-cheatsheet"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackjutsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-12T18:45:39.000Z","updated_at":"2025-03-23T02:55:04.000Z","dependencies_parsed_at":"2022-09-12T18:42:10.004Z","dependency_job_id":null,"html_url":"https://github.com/hackjutsu/vim-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2Fvim-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2Fvim-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2Fvim-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2Fvim-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackjutsu","download_url":"https://codeload.github.com/hackjutsu/vim-cheatsheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198463,"owners_count":20900080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","keyboard-shortcuts","vim","vim-cheatsheet"],"created_at":"2024-08-02T13:01:52.445Z","updated_at":"2025-04-04T15:11:00.245Z","avatar_url":"https://github.com/hackjutsu.png","language":null,"readme":"# Vim Cheatsheet\n\n\u003eDisclaimer: This cheatsheet is summarized from personal experience and other online tutorials. It should not be considered as an official advice.\n\n## Global\n```bash\n:help keyword # open help for keyword\n:o file       # open file\n:saveas file  # save file as\n:close        # close current pane\n```\n\n## Cursor movement\n```bash\nh        # move cursor left\nj        # move cursor down\nk        # move cursor up\nl        # move cursor right\nH        # move to top of screen\nM        # move to middle of screen\nL        # move to bottom of screen\nw        # jump forwards to the start of a word\nW        # jump forwards to the start of a word (words can contain punctuation)\ne        # jump forwards to the end of a word\nE        # jump forwards to the end of a word (words can contain punctuation)\nb        # jump backwards to the start of a word\nB        # jump backwards to the start of a word (words can contain punctuation)\n0        # jump to the start of the line\n^        # jump to the first non-blank character of the line\n$        # jump to the end of the line\ng_       # jump to the last non-blank character of the line\ngg       # go to the first line of the document\nG        # go to the last line of the document\n5G       # go to line 5\nfx       # jump to next occurrence of character x\ntx       # jump to before next occurrence of character x\n}        # jump to next paragraph (or function/block, when editing code)\n{        # jump to previous paragraph (or function/block, when editing code)\nzz       # center cursor on screen\nCtrl + b # move back one full screen\nCtrl + f # move forward one full screen\nCtrl + d # move forward 1/2 a screen\nCtrl + u # move back 1/2 a screen\n```\n\n## Insert mode - inserting/appending text\n```bash\ni        # insert before the cursor\nI        # insert at the beginning of the line\na        # insert (append) after the cursor\nA        # insert (append) at the end of the line\no        # append (open) a new line below the current line\nO        # append (open) a new line above the current line\nea       # insert (append) at the end of the word\nEsc      # exit insert mode\n```\n\n## Editing\n```bash\nr        # replace a single character\nJ        # join line below to the current one\ncc       # change (replace) entire line\ncw       # change (replace) to the start of the next word\nce       # change (replace) to the end of the next word\ncb       # change (replace) to the start of the previous word\nc0       # change (replace) to the start of the line\nc$       # change (replace) to the end of the line\ns        # delete character and substitute text\nS        # delete line and substitute text (same as cc)\nxp       # transpose two letters (delete and paste)\n.        # repeat last command\nu        # undo\nCtrl + r # redo\n```\n\n## Marking text (visual mode)\n```bash\nv        # start visual mode, mark lines, then do a command (like y-yank)\nV        # start linewise visual mode\no        # move to other end of marked area\nO        # move to other corner of block\naw       # mark a word\nab       # a block with ()\naB       # a block with {}\nib       # inner block with ()\niB       # inner block with {}\nEsc      # exit visual mode\nCtrl + v # start visual block mode\n```\n\n## Visual commands\n```bash\n\u003e       # shift text right\n\u003c       # shift text left\ny       # yank (copy) marked text\nd       # delete marked text\n~       # switch case\n```\n\n## Cut and paste\n```bash\nyy       # yank (copy) a line\n2yy      # yank (copy) 2 lines\nyw       # yank (copy) the characters of the word from the cursor position to the start of the next word\ny$       # yank (copy) to end of line\np        # put (paste) the clipboard after cursor\nP        # put (paste) before cursor\ndd       # delete (cut) a line\n2dd      # delete (cut) 2 lines\ndw       # delete (cut) the characters of the word from the cursor position to the start of the next word\nD        # delete (cut) to the end of the line\nd$       # delete (cut) to the end of the line\nd^       # delete (cut) to the first non-blank character of the line\nd0       # delete (cut) to the begining of the line\nx        # delete (cut) character\n```\n\n## Search and replace\n```bash\n/pattern       # search for pattern\n?pattern       # search backward for pattern\n\\vpattern      # 'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed)\nn              # repeat search in same direction\nN              # repeat search in opposite direction\n:%s/old/new/g  # replace all old with new throughout file\n:%s/old/new/gc # replace all old with new throughout file with confirmations\n:noh           # remove highlighting of search matches\n```\n\n## Search in multiple files\n```bash\n:vimgrep /pattern/ {file} # search for pattern in multiple files\n:cn                       # jump to the next match\n:cp                       # jump to the previous match\n:copen                    # open a window containing the list of matches\n```\n\n## Exiting\n```bash\n:w              # write (save) the file, but don't exit\n:w !sudo tee %  # write out the current file using sudo\n:wq or :x or ZZ # write (save) and quit\n:q              # quit (fails if there are unsaved changes)\n:q! or ZQ       # quit and throw away unsaved changes\n```\n\n## Working with multiple files\n```bash\n:e file       # edit a file in a new buffer\n:bnext or :bn # go to the next buffer\n:bprev or :bp # go to the previous buffer\n:bd           # delete a buffer (close a file)\n:ls           # list all open buffers\n:sp file      # open a file in a new buffer and split window\n:vsp file     # open a file in a new buffer and vertically split window\nCtrl + ws     # split window\nCtrl + ww     # switch windows\nCtrl + wq     # quit a window\nCtrl + wv     # split window vertically\nCtrl + wh     # move cursor to the left window (vertical split)\nCtrl + wl     # move cursor to the right window (vertical split)\nCtrl + wj     # move cursor to the window below (horizontal split)\nCtrl + wk     # move cursor to the window above (horizontal split)\n```\n\n## Tabs\n```bash\n:tabnew or :tabnew file # open a file in a new tab\nCtrl + wT               # move the current split window into its own tab\ngt or :tabnext or :tabn # move to the next tab\ngT or :tabprev or :tabp # move to the previous tab\n\u003cnumber\u003egt              # move to tab \u003cnumber\u003e\n:tabmove \u003cnumber\u003e       # move current tab to the \u003cnumber\u003eth position (indexed from 0)\n:tabclose or :tabc      # close the current tab and all its windows\n:tabonly or :tabo       # close all tabs except for the current one\n:tabdo command          # run the command on all tabs (e.g. :tabdo q - closes all opened tabs)\n```\n","funding_links":[],"categories":["Others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackjutsu%2Fvim-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackjutsu%2Fvim-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackjutsu%2Fvim-cheatsheet/lists"}