VI Cheat Sheet: Difference between revisions

From Coolscript
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 5: Line 5:


=Command=
=Command=
  :w filename - write to file system with specific file name
  ''':w filename''' - write to file system with specific file name
  :w - write file out if vim already knows the file name
  ''':w - write file''' out if vim already knows the file name
  :wq - writes and quits vim
  ''':wq''' - writes and quits vim
  :q! - quits vim when a buffer has edits
  ''':q!''' - quits vim when a buffer has edits
  :q - quits vim
  ''':q''' - quits vim
  shift A - goes into insert mode at end of line (didn't mention on video)
  '''shift A''' - goes into insert mode at end of line


=Normal Mode Navigation:=
=Normal Mode Navigation:=
  j - down
  '''j''' - down
  k - up
  '''k''' - up
  h - left
  '''h''' - left
  l - right
  '''l''' - right
  gg - top of file
  '''gg''' - top of file
  G - bottom of tile
  '''G''' - bottom of tile
  number gg - goes to specific line number  
  '''number gg''' - goes to specific line number
  OR
'''number <shift> g''' - goes to specific line number
  OR
'''<shift> g''' - goes to the end


=search/find/replace=
=search/find/replace=
  /searchTerm - searches for current text
  '''/searchTerm''' - searches for current text
  n - goes to the next location of the searched text
  '''n''' - goes to the next location of the searched text
  ?searchTerm - searches backwards for current text
  '''?searchTerm''' - searches backwards for current text
  * - searches for the current text the cursor is on
  '''*''' - searches for the current text the cursor is on
''':%s/findText/replaceText''' - searches all text and replaces text no confirmation.
''':%s/findText/repalceText/c''' - searches text and confirms each replace.
'''uu''' undo above


=Copy/Paste/Cut=
=Copy/Paste/Cut=
  v - enter visual mode (select text with hjkl)
  '''v''' - enter visual mode (select text with hjkl)
  y - yanks text
  '''y''' - yanks text
  dd Cut Line
  '''dd''' Cut Line
  :put - paste text after current line
  ''':put''' - paste text/line after current line
  p - paste at current position
  '''p''' - paste at current position
 
=Goto=
*type the line number, and then press Shift-g

Latest revision as of 13:44, 7 October 2021

Mode

i - insert mode
esc - normal mode

Command

:w filename - write to file system with specific file name
:w - write file out if vim already knows the file name
:wq - writes and quits vim
:q! - quits vim when a buffer has edits
:q - quits vim
shift A - goes into insert mode at end of line

Normal Mode Navigation:

j - down
k - up
h - left
l - right
gg - top of file
G - bottom of tile
number gg - goes to specific line number
 OR
number <shift> g - goes to specific line number
 OR
<shift> g - goes to the end

search/find/replace

/searchTerm - searches for current text
n - goes to the next location of the searched text
?searchTerm - searches backwards for current text
* - searches for the current text the cursor is on
:%s/findText/replaceText - searches all text and replaces text no confirmation.
:%s/findText/repalceText/c - searches text and confirms each replace.
uu undo above

Copy/Paste/Cut

v - enter visual mode (select text with hjkl)
y - yanks text
dd Cut Line
:put - paste text/line after current line
p - paste at current position