From d498e53e807f72b48b80a13f76ad6bd8167807da Mon Sep 17 00:00:00 2001 From: Sushant Agawane Date: Sun, 9 Oct 2022 12:05:51 +0530 Subject: [PATCH 1/3] Adds VIM cheatsheet for developers --- vim_CheatSheet.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 vim_CheatSheet.md diff --git a/vim_CheatSheet.md b/vim_CheatSheet.md new file mode 100644 index 0000000..647fbb8 --- /dev/null +++ b/vim_CheatSheet.md @@ -0,0 +1,85 @@ + + + #Insert mode + i + + #Insert after cursor + a + + #Create blank line below & insert + o + + #Normal mode + esc key + + #Write changes + :w + + #Quit without saving changes + :q! + + #Write and quit + :wq + + #Enter visual mode to select characters + v + + #Enter visual mode to select line + V + + #Cut(Delete) selected text + d + + #Cut current line + dd + + #Copy(Yank) selected text + y + + #Copy current line + y$ + + #Paste after cursor + p + + #Paste before cursor + P + + #Undo vim action + u + + #Redo vim action + ctrl + r + + #Open a bash session from Vim + :! bash + + #Exit a bash session to go back to Vim + exit + + #Turn word-wrap on/off + :set wrap + :set nowrap + + #Turn line numbers on/off + :set number + :set nonumber + + #Open multiple files in new tabs (from bash prompt) + vim -p ... + + #Quick switch to next tab + gt + + #Quick switch to previous tab + gT + + #Save tab session to file + :mksession + + #Load saved tab session (from bash prompt) + vim -S + + #Search and replace all patterns found in file + :%s///g + From db2089c4f54b42c5e77ff2588f3a6c1d2550cd63 Mon Sep 17 00:00:00 2001 From: Sushant Agawane Date: Wed, 12 Oct 2022 21:55:28 +0530 Subject: [PATCH 2/3] Fixes VIM CheatSheet --- vim_CheatSheet.md | 187 +++++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 84 deletions(-) diff --git a/vim_CheatSheet.md b/vim_CheatSheet.md index 647fbb8..67f5ad7 100644 --- a/vim_CheatSheet.md +++ b/vim_CheatSheet.md @@ -1,85 +1,104 @@ +--- +title: Vim +description: Vim is a text editor for Unix that comes with Linux, BSD, and macOS +created: 2022-10-09 +updated: 2022-10-12 +--- + +### Exiting + +```sh +:qa # Close all files +:qa! # Close all files, abandon changes +:w # Save +:wq / :x # Save and close file +:q # close file +:q! # Close file, abandon changes +ZZ # Save and quit +ZQ # Quit without checking changes +``` +### Exiting insert mode + +```sh +Esc / # Exit insert mode + # Exit insert mode, and abort current command +``` + +### Visual mode + +```sh +v # Enter visual mode +V # Enter visual line mode + # Enter visual block mode +d / x # Delete selection +s # Replace selection +``` + +### Navigating + +```sh +h j k l # Arrow keys + / # Half-page up/down + / # Page up/down +b / w # Previous/next word +ge / e # Previous/next end of word +fc # Go forward to character c +Fc # Go backward to character c +gg # First line +G # Last line +zz # Center this line +zb # Bottom this line +n # Next matching search pattern +N # Previous match +* # Next whole word under cursor +^ # Start of line (after whitespace) +``` + +### Editing + +```sh +a # Append +A # Append from end of line +i # Insert +o # Next line +O # Previous line +S # Delete line and insert +C # Delete until end of line and insert + # Redo changes +``` + +### Clipboard + +```sh +x # Delete character +dd # Delete line (Cut) +yy # Yank line (Copy) +"*p / "+p # Paste from system clipboard +"*y / "+y # Paste to system clipboard +``` + +### Jumping + +```sh + # Go back to previous location + # Go forward +gf # Go to file in cursor +``` + +### Counters + +```sh + # Increment number + # Decrement +``` + +### Spell Checking + +```sh +]s # Move to next misspelled word after the cursor +[s # Move to previous misspelled word before the cursor +z= # Suggest spellings for the word under/after the cursor +zg # Add word to spell list +zw # Mark word as bad/mispelling +``` - - #Insert mode - i - - #Insert after cursor - a - - #Create blank line below & insert - o - - #Normal mode - esc key - - #Write changes - :w - - #Quit without saving changes - :q! - - #Write and quit - :wq - - #Enter visual mode to select characters - v - - #Enter visual mode to select line - V - - #Cut(Delete) selected text - d - - #Cut current line - dd - - #Copy(Yank) selected text - y - - #Copy current line - y$ - - #Paste after cursor - p - - #Paste before cursor - P - - #Undo vim action - u - - #Redo vim action - ctrl + r - - #Open a bash session from Vim - :! bash - - #Exit a bash session to go back to Vim - exit - - #Turn word-wrap on/off - :set wrap - :set nowrap - - #Turn line numbers on/off - :set number - :set nonumber - - #Open multiple files in new tabs (from bash prompt) - vim -p ... - - #Quick switch to next tab - gt - - #Quick switch to previous tab - gT - - #Save tab session to file - :mksession - - #Load saved tab session (from bash prompt) - vim -S - - #Search and replace all patterns found in file - :%s///g - From c5c159849cd74b6d441ea3a3991fa8c5f38a5893 Mon Sep 17 00:00:00 2001 From: Sushant Agawane Date: Wed, 12 Oct 2022 21:58:35 +0530 Subject: [PATCH 3/3] Fixes file name --- vim_CheatSheet.md => vim_cheatsheet.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename vim_CheatSheet.md => vim_cheatsheet.md (100%) diff --git a/vim_CheatSheet.md b/vim_cheatsheet.md similarity index 100% rename from vim_CheatSheet.md rename to vim_cheatsheet.md