{"id":24387093,"url":"https://github.com/heimdev/vim-cheat-sheet","last_synced_at":"2025-03-12T19:27:20.793Z","repository":{"id":240688068,"uuid":"561711185","full_name":"heimdev/vim-cheat-sheet","owner":"heimdev","description":"Vim text editor cheat sheet","archived":false,"fork":false,"pushed_at":"2023-01-09T10:13:07.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T12:16:37.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/heimdev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-04T10:11:26.000Z","updated_at":"2022-12-25T19:21:34.000Z","dependencies_parsed_at":"2024-05-20T16:41:21.328Z","dependency_job_id":null,"html_url":"https://github.com/heimdev/vim-cheat-sheet","commit_stats":null,"previous_names":["cryp7ic/vim-cheat-sheet","heimdev/vim-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimdev%2Fvim-cheat-sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimdev%2Fvim-cheat-sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimdev%2Fvim-cheat-sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimdev%2Fvim-cheat-sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heimdev","download_url":"https://codeload.github.com/heimdev/vim-cheat-sheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243279992,"owners_count":20265936,"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":[],"created_at":"2025-01-19T12:16:35.532Z","updated_at":"2025-03-12T19:27:20.788Z","avatar_url":"https://github.com/heimdev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vim Cheat Sheet\n\nI’ve compiled a list of essential Vim commands that I use every day. I have then given a few instructions on how to make Vim as great as it should be, because it’s painful without configuration.\n\n## Essentials\n\n### Cursor movement (Normal/Visual Mode)\n\n-   `h` `j` `k` `l` - Arrow keys\n-   `w` / `b` - Next/previous word\n-   `W` / `B` - Next/previous word (space seperated)\n-   `e` / `ge` - Next/previous end of word\n-   `0` / `$` - Start/End of line\n-   `^` - First non-blank character of line (same as `0w`)\n\n### Editing text\n\n-   `i` / `a` - Start insert mode at/after cursor\n-   `I` / `A` - Start insert mode at the beginning/end of the line\n-   `o` / `O` - Add blank line below/above current line\n-   `Esc` or `Ctrl+[` - Exit insert mode\n-   `d` - Delete\n-   `dd` - Delete line\n-   `c` - Delete, then start insert mode\n-   `cc` - Delete line, then start insert mode\n\n### Operators\n\n-   Operators also work in Visual Mode\n-   `d` - Deletes from the cursor to the movement location\n-   `c` - Deletes from the cursor to the movement location, then starts insert mode\n-   `y` - Copy from the cursor to the movement location\n-   `\u003e` - Indent one level\n-   `\u003c` - Unindent one level\n-   You can also combine operators with motions. Ex: `d$` deletes from the cursor to the end of the line.\n\n### Marking text (visual mode)\n\n-   `v` - Start visual mode\n-   `V` - Start linewise visual mode\n-   `Ctrl+v` - Start visual block mode\n-   `Esc` or `Ctrl+[` - Exit visual mode\n\n### Clipboard\n\n-   `yy` - Yank (copy) a line\n-   `p` - Paste after cursor\n-   `P` - Paste before cursor\n-   `dd` - Delete (cut) a line\n-   `x` - Delete (cut) current character\n-   `X` - Delete (cut) previous character\n-   `d` / `c` - By default, these copy the deleted text\n-   `:1,3co6` - Copies lines 1 through 3 and pastes them after line 6\n-   `:4,6m9` - Moves lines 4 through 6 after line 9\n\n### Exiting\n\n-   `:w` - Write (save) the file, but don’t quit\n-   `:wq` - Write (save) and quit\n-   `:q` - Quit (fails if anything has changed)\n-   `:q!` - Quit and throw away changes\n\n### Search/Replace\n\n-   `/pattern` - Search for pattern\n-   `?pattern` - Search backward for pattern\n-   `n` - Repeat search in same direction\n-   `N` - Repeat search in opposite direction\n-   `:%s/old/new/g` - Replace all old with new throughout file ([gn](http://vimcasts.org/episodes/operating-on-search-matches-using-gn/) is better though)\n-   `:%s/old/new/gc` - Replace all old with new throughout file with confirmations\n\n### General\n\n-   `u` - Undo\n-   `Ctrl+r` - Redo\n\n## Advanced\n\n### Cursor movement\n\n-   `Ctrl+d` - Move down half a page\n-   `Ctrl+u` - Move up half a page\n-   `}` - Go forward by paragraph (the next blank line)\n-   `{` - Go backward by paragraph (the next blank line)\n-   `gg` - Go to the top of the page\n-   `G` - Go the bottom of the page\n-   `: [num] [enter]` - Go to that line in the document\n-   `ctrl+e / ctrl+y` - Scroll down/up one line\n\n### Character search\n\n-   `f [char]` - Move forward to the given char\n-   `F [char]` - Move backward to the given char\n-   `t [char]` - Move forward to before the given char\n-   `T [char]` - Move backward to before the given char\n-   `;` / `,` - Repeat search forwards/backwards\n\n### Editing text\n\n-   `J` - Join line below to the current one\n-   `r [char]` - Replace a single character with the specified char (does not use Insert mode)\n\n### Visual mode\n\n-   `O` - Move to other corner of block\n-   `o` - Move to other end of marked area\n\n### File Tabs\n\n-   `:e filename` - Edit a file\n-   `:tabe` - Make a new tab\n-   `gt` - Go to the next tab\n-   `gT` - Go to the previous tab\n-   `:vsp` - Vertically split windows\n-   `ctrl+ws` - Split windows horizontally\n-   `ctrl+wv` - Split windows vertically\n-   `ctrl+ww` - Switch between windows\n-   `ctrl+wq` - Quit a window\n\n### Marks\n\n-   Marks allow you to jump to designated points in your code.\n-   `m{a-z}` - Set mark {a-z} at cursor position\n-   A capital mark {A-Z} sets a global mark and will work between files\n-   `'{a-z}` - Move the cursor to the start of the line where the mark was set\n-   `''` - Go back to the previous jump location\n\n### Text Objects\n\n-   Say you have `def (arg1, arg2, arg3)`, where your cursor is somewhere in the middle of the parenthesis.\n-   `di(` deletes everything between the parenthesis. That says “change everything inside the nearest parenthesis”. Without text objects, you would need to do `T(dt)`.\n-   [Learn more](http://blog.carbonfive.com/2011/10/17/vim-text-objects-the-definitive-guide/)\n\n### General\n\n-   `.` - Repeat last command\n-   `Ctrl+r + 0` in insert mode inserts the last yanked text (or in command mode)\n-   `gv` - reselect (select last selected block of text, from visual mode)\n-   `%` - jumps between matching `()` or `{}`\n\n# Making VIM actually useful\n\nVim is quite unpleasant out of the box. It’s an arcane experience:\n\n-   Autocomplete is missing\n-   System clipboard is not used\n-   Act of typing `:w` to save is cumbersome\n-   Mouse doesn’t work\n-   Management of multiple files is tricky\n-   Integration with other plugins (like compiler warnings) is challenging\n-   Repeatedly indenting/unindenting multiple lines is challenging, though possible\n\nIt does have a significant strength though: your fingers can stay on the main keyboard keys to do most editing actions. This is faster and more ergonomic. I find that the toughest part about VIM is guiding people towards getting the benefits of VIM without the drawbacks. Here are some ideas on how to go about this.\n\n## Switch caps lock and escape\n\n-   I highly recommend you switch the mapping of your caps lock and escape keys. You’ll love it, promise! Switching the two keys is platform dependent.\n\n## Visual Studio Code\n\n-   VSCode is the simplest way to give you a fantastic editor that also gives you the benefits of VIM. Just install [the VIM extension](https://marketplace.visualstudio.com/items?itemName=vscodevim.vim).\n-   I made a [few slight changes](https://gist.github.com/theicfire/dc3f7f8c9a19467643a58dff22eb00d9) which improved the experience for me.\n\n## Configure native VIM\n\nFor all the given limitations, you’ll need to find a solution. You can either solve the issues one by one, or you can use a reference .vimrc settings file that fix most of the issues out-of-the-box.\n\n-   [My .vimrc file](https://github.com/theicfire/dotfiles/blob/master/vim/.vimrc) could be a good starting point. Honestly, it’s a bit old and not the best. I now use VSCode mainly so I haven’t kept a great vimrc.\n\n### Using the system clipboard\n\n-   `\"+y` copy a selection to the system clipboard\n-   `\"+p` paste from the system clipboard\n-   If this doesn’t work, it’s probably because Vim was not built with the system clipboard option. To check, run `vim --version` and see if `+clipboard` exists. If it says `-clipboard`, you will not be able to copy from outside of Vim.\n    -   For Mac users, homebrew install Vim with the clipboard option. Install homebrew and then run `brew install vim`.\n        -   then move the old Vim binary: `$ mv /usr/bin/vim /usr/bin/vimold`\n        -   restart your terminal and you should see `vim --version` now with `+clipboard`\n\n## Sublime Text\n\n-   Another option is to use Vintageous in Sublime Text (version 3). This gives you Vim mode inside Sublime. I suggest this (or a similar setup with the Atom editor) if you aren’t a Vim master. Check out [Advanced Vim](https://vimsheet.com/advanced.html) if you are.\n-   Vintageous is great, but I suggest you change a few settings to make it better.\n    \n    -   Clone [this repository](https://github.com/theicfire/Vintageous) to `~/.config/sublime-text-3/Packages/Vintageous`, or similar. Then check out the “custom” branch.\n        -   Alternatively, you can get a more updated Vintageous version by cloning [the official](https://github.com/guillermooo/Vintageous) repository and then copying over [this patch](https://github.com/theicfire/Vintageous/commit/19ff6311b01e3ae259b7eb8e3944687b42ba06ff).\n    -   Change the user settings (`User/Preferences.sublime-settings`) to include:\n        -   `\"caret_style\": \"solid\"`\n        -   This will make the cursor not blink, like in Vim.\n        -   Sublime Text might freeze when you do this. It’s a bug; just restart Sublime Text after changing the file.\n    -   `ctrl+r` in Vim means “redo”. But there is a handy Ctrl + R shortcut in Sublime Text that gives an “outline” of a file. I remapped it to alt+r by putting this in the User keymap\n        -   `{ \"keys\": [\"alt+r\"], \"command\": \"show_overlay\", \"args\": {\"overlay\": \"goto\", \"text\": \"@\"} },`\n    -   [Add the ability to toggle Vintageous on and off](https://github.com/guillermooo/Vintageous/wiki/Toggling-Vintageous)\n    -   Mac users: you will not have the ability to hold down a navigation key (like holding j to go down). To fix this, run the commands specified here: [https://gist.github.com/kconragan/2510186](https://gist.github.com/kconragan/2510186)\n-   Now you should be able to restart sublime and have a great Vim environment! Sweet Dude.\n\n## Other\n\nI don’t personally use these yet, but I’ve heard other people do!\n\n-   `:qa` - Quit all open tabs (thanks Vince Banzon)\n-   `:wa` - Write all open tabs (thanks Vince Banzon)\n-   `:wqa` - Write and quit all open tabs (thanks Brian Zick)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimdev%2Fvim-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheimdev%2Fvim-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimdev%2Fvim-cheat-sheet/lists"}