aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/cheat/vim
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-05 07:05:07 +0200
committerneodarz <neodarz@neodarz.net>2019-09-05 07:05:07 +0200
commite0c0d4b38cde20e2300e86b69414dd9851b47456 (patch)
tree5df65243447352a9637d1f783247bfd5ccff2ef4 /dotfiles/cheat/vim
parentdc45bf89a66ec6c8cd25cf5605deb853f6984705 (diff)
downloaddotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.tar.xz
dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.zip
ooo
Diffstat (limited to 'dotfiles/cheat/vim')
-rw-r--r--dotfiles/cheat/vim80
1 files changed, 80 insertions, 0 deletions
diff --git a/dotfiles/cheat/vim b/dotfiles/cheat/vim
new file mode 100644
index 0000000..ebc509d
--- /dev/null
+++ b/dotfiles/cheat/vim
@@ -0,0 +1,80 @@
+# File management
+
+:e reload file
+:q quit
+:q! quit without saving changes
+:w write file
+:w {file} write new file
+:x write file and exit
+
+# Movement
+
+ k
+ h l basic motion
+ j
+
+w next start of word
+W next start of whitespace-delimited word
+e next end of word
+E next end of whitespace-delimited word
+b previous start of word
+B previous start of whitespace-delimited word
+0 start of line
+$ end of line
+gg go to first line in file
+G go to end of file
+gk move down one displayed line
+gj move up one displayed line
+
+# Insertion
+# To exit from insert mode use Esc or Ctrl-C
+# Enter insertion mode and:
+
+a append after the cursor
+A append at the end of the line
+i insert before the cursor
+I insert at the beginning of the line
+o create a new line under the cursor
+O create a new line above the cursor
+R enter insert mode but replace instead of inserting chars
+:r {file} insert from file
+
+# Editing
+
+u undo
+yy yank (copy) a line
+y{motion} yank text that {motion} moves over
+p paste after cursor
+P paste before cursor
+<Del> or x delete a character
+dd delete a line
+d{motion} delete text that {motion} moves over
+
+# Search and replace with the `:substitute` (aka `:s`) command
+
+:s/foo/bar/ replace the first match of 'foo' with 'bar' on the current line only
+:s/foo/bar/g replace all matches (`g` flag) of 'foo' with 'bar' on the current line only
+:%s/foo/bar/g replace all matches of 'foo' with 'bar' in the entire file (`:%s`)
+:%s/foo/bar/gc ask to manually confirm (`c` flag) each replacement
+
+# Preceding a motion or edition with a number repeats it 'n' times
+# Examples:
+50k moves 50 lines up
+2dw deletes 2 words
+5yy copies 5 lines
+42G go to line 42
+
+# Multi line select and edit
+1. Press Esc to enter 'command mode'
+2. Use Ctrl + V to enter visual block mode.
+3. Move Up / Down to select the columns of text in the lines you want to comment.
+4. Then hit Shift + i and type the text you want to insert.
+5. Then hit Esc , wait 1 second and the inserted text will appear on every line.
+
+# Use normal copy pase
+`"`; `+` ; `y` <= yank
+`"`; `+` ; `p` <= paste
+
+# SimpleWorkspaces.vim
+To add the current dir in a Workspace: `:WorkspaceInit`
+And save it in a better name: `:WorkspaceSave {name}`