vi and vim - Paiet/Tech-Journal-for-Everything GitHub Wiki
- vi
- VIsual Editor
- Developed for Unix
- vim
- Vi Improved
- Significantly larger feature set
- Most distros link
/bin/vi to /bin/vim
- Opening a file
- Command Mode
- Insert Mode
-
i
- Insert at current location
-
I
- Insert at beginning of line
-
o
-
a
-
A
- Closing a file
-
:w
- Save file
-
:w <filename> to "Save As"
-
:wq or :x
-
:q!
- Deleting text
- Copy and Paste
-
y (yank)
-
p (put)
-
p - Paste buffer after the current line
- Moving without arrow keys
- Ranges
:#,#<command>
-
:1,10d
-
:set number
- Displays line numbers
-
:set number! to disable
-
vi +# filename opens a file to a particular line
- To be permanent
vi ~/.vimrc
set number
- Search
-
/<string> or :s/<string>
- Search forward for text
-
? for backward
-
n for next
-
N for previous
-
vi +/<text> filename.txt
- Opens a file to the first occurrence of a term
- Search and Replace
-
:s/<findtext>/<replacetext>
- Replaces text on one line
-
:%s/<findtext>/<replacetext>
- Replaces text throughout the file
-
:#,#s/<findtext>/<replacetext>
- Replaces text within a range
⚠️ **GitHub.com Fallback** ⚠️