{"slug": "vim-a-great-vim-cheat-sheet", "title": "VIM: A Great Vim Cheat Sheet", "summary": "The article provides a comprehensive cheat sheet of essential Vim commands, organized by categories such as cursor movement, text editing, visual mode, and file management. It includes basic and advanced commands for navigation, searching, cutting and pasting, and working with multiple files. The summary notes that Vim requires configuration to be fully effective, as it is \"painful without configuration.\"", "body_md": "#A Great Vim Cheat Sheet\nNote: If you’re decent at vim and want your mind blown, check out Advanced Vim.\nI’ve compiled a list of essential vim commands that I use every day. I then give a few instructions on how to making vim as great as it should be, because it’s painful without configuration.\n##Cursor movement (Inside command/normal mode)\nw\n- jump by start of words (punctuation considered words)W\n- jump by words (spaces separate words)e\n- jump to end of words (punctuation considered words)E\n- jump to end of words (no punctuation)b\n- jump backward by words (punctuation considered words)B\n- jump backward by words (no punctuation)0\n- (zero) start of line^\n- first non-blank character of line (same as 0w)$\n- end of line- Advanced (in order of what I find useful)\nCtrl+d\n- move down half a pageCtrl+u\n- move up half a page}\n- go forward by paragraph (the next blank line){\n- go backward by paragraph (the next blank line)gg\n- go to the top of the pageG\n- go the bottom of the page: [num] [enter]\n- Go To that line in the document- Searching\nf [char]\n- Move to the next char on the current line after the cursorF [char]\n- Move to the next char on the current line before the cursort [char]\n- Move to before the next char on the current line after the cursorT [char]\n- Move to before the next char on the current line before the cursor- All these commands can be followed by\n;\n(semicolon) to go to the next searched item, and,\n(comma) to go the the previous searched item\n##Insert/Appending/Editing Text\n- Results in insert mode\ni\n- start insert mode at cursorI\n- insert at the beginning of the linea\n- append after the cursorA\n- append at the end of the lineo\n- open (append) blank line below current line (no need to press return)O\n- open blank line above current linecc\n- change (replace) an entire linec [movement command]\n- change (replace) from the cursor to the move-to point.- ex.\nce\nchanges from the cursor to the end of the cursor word\n- Esc - exit insert mode\nr [char]\n- replace a single character with the specified char (does not use insert mode)d\n- deleted\n- [movement command] deletes from the cursor to the move-to point.- ex.\nde\ndeletes from the cursor to the end of the current word\ndd\n- delete the current line- Advanced\nJ\n- join line below to the current one\n##Marking text (visual mode)\nv\n- starts visual mode- From here you can move around as in normal mode (hjkl etc.) and can then do a command (such as\ny\n,d\n, orc\n)\n- From here you can move around as in normal mode (hjkl etc.) and can then do a command (such as\nV\n- starts linewise visual modeCtrl+v\n- start visual block modeEsc\n- exit visual mode- Advanced\nO\n- move to Other corner of blocko\n- move to other end of marked area\n##Visual commands Type any of these while some text is selected to apply the action\ny\n- yank (copy) marked textd\n- delete marked textc\n- delete the marked text and go into insert mode (like c does above)\n##Cut and Paste\nyy\n- yank (copy) a linep\n- put (paste) the clipboard after cursorP\n- put (paste) before cursordd\n- delete (cut) a linex\n- delete (cut) current characterX\n- delete previous character (like backspace)\n##Exiting\n:w\n- write (save) the file, but don't exit:wq\n- write (save) and quit:q\n- quit (fails if anything has changed):q!\n- quit and throw away changes\n##Search/Replace\n/pattern\n- search for pattern?pattern\n- search backward for patternn\n- repeat search in same directionN\n- repeat search in opposite direction:%s/old/new/g\n- replace all old with new throughout file (gn is better though):%s/old/new/gc\n- replace all old with new throughout file with confirmations\n##Working with multiple files\n:e filename\n- Edit a file:tabe\n- make a new tabgt\n- go to the next tabgT\n- go to the previous tab- Advanced\n:vsp\n- vertically split windowsctrl+ws\n- Split windows horizontallyctrl+wv\n- Split windows verticallyctrl+ww\n- switch between windowsctrl+wq\n- Quit a window\n##Marks Marks allow you to jump to designated points in your code.\nm{a-z}\n- Set mark {a-z} at cursor position- A capital mark {A-Z} sets a global mark and will work between files\n‘{a-z}\n- move the cursor to the start of the line where the mark was set‘’\n- go back to the previous jump location\n##General\nu\n- undoCtrl+r\n- redo.\n- repeat last command\n#Making Vim actually useful\nVim is quite unpleasant out of the box. For example, typeing :w\nfor every file save is awkward and copying and pasting to the system clipboard does not work. But a few changes will get you much closer to the editor of your dreams.\n##.vimrc\n- My .vimrc file has some pretty great ideas I haven't seen elsewhere.\n- This is a minimal vimrc that focuses on three priorities:\n- adding options that are strictly better (like more information showing in autocomplete)\n- more convenient keystrokes (like\n[space]w\nfor write, instead of:w [enter]\n) - a similar workflow to normal text editors (like enabling the mouse)\n- Copy this to your home directory and restart vim. Read through it to see what you can now do (like\n[space]w\nto save a file)- mac users - making a hidden normal file is suprisingly tricky. Here’s one way:\n- in the command line, go to the home directory\n- type\nnano .vimrc\n- paste in the contents of the .vimrc file\nctrl+x\n,y\n,[enter]\nto save\n- mac users - making a hidden normal file is suprisingly tricky. Here’s one way:\n- You should now be able to press\n[space]w\nin normal mode to save a file. [space]p\nshould paste from the system clipboard (outside of vim).- If you can’t paste, it’s probably because vim was not built with the system clipboard option. To check, run\nvim --version\nand see if+clipboard\nexists. If it says-clipboard\n, you will not be able to copy from outside of vim. - For mac users, homebrew install vim with the clipboard option. Install homebrew and then run\nbrew install vim\n.- then move the old vim binary:\n$ mv /usr/bin/vim /usr/bin/vimold\n- restart your terminal and you should see\nvim --version\nnow with+clipboard\n- then move the old vim binary:\n- If you can’t paste, it’s probably because vim was not built with the system clipboard option. To check, run\n##Plugins\n-\nThe easiest way to make vim more powerful is to use Vintageous in sublime (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 if you are.\n-\nVintageous is great, but I suggest you change a few settings to make it better.\n- Clone this repository to\n~/.config/sublime-text-3/Packages/Vintageous\n, or similar. Then check out the \"custom\" branch.- Alternatively, you can get a more updated Vintageous version by cloning the official repo and then copying over this patch.\n- Change the user settings (\nUser/Preferences.sublime-settings\n) to include:\"caret_style\": \"solid\"\n- This will make the cursor not blink, like in vim.\n- sublime might freeze when you do this. It’s a bug; just restart sublime after changing the file.\nctrl+r\nin vim means \"redo\". But there is a handy ctrl+r shortcut in sublime that gives an \"outline\" of a file. I remapped it to alt+r by putting this in the User keymap{ \"keys\": [\"alt+r\"], \"command\": \"show_overlay\", \"args\": {\"overlay\": \"goto\", \"text\": \"@\"} },\n- Add the ability to toggle vintageous on and off\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\n- Clone this repository to\n-\nNow you should be able to restart sublime and have a great vim environment! Sweet Dude.\n##Switch Caps Lock and Escape\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; google should get you the answer\n##Other I don’t personally use these yet, but I’ve heard other people do!\n:wqa\n- Write and quit all open tabs (thanks Brian Zick)", "url": "https://wpnews.pro/news/vim-a-great-vim-cheat-sheet", "canonical_source": "https://gist.github.com/etasi/44f2d182d3c531c8fbd8", "published_at": "2015-02-17 23:05:34+00:00", "updated_at": "2026-05-23 16:35:22.769291+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Vim"], "alternates": {"html": "https://wpnews.pro/news/vim-a-great-vim-cheat-sheet", "markdown": "https://wpnews.pro/news/vim-a-great-vim-cheat-sheet.md", "text": "https://wpnews.pro/news/vim-a-great-vim-cheat-sheet.txt", "jsonld": "https://wpnews.pro/news/vim-a-great-vim-cheat-sheet.jsonld"}}