version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 author=Limits charset=UTF-8 csum=Add Introduction to Vi ctime=1645978593 host=2409:4060:18:a55b:cb97:acd0:80cb:9543 name=Vi.Intro rev=1 targets= text=(:title Vi Introduction:)%0a%0aVi is the free and open-source editor that is present on most UNIX systems.%0aVi is a modal editor. It has three main modes (ways to interact with the editor).%0a[[https://en.m.wikibooks.org/wiki/Learning_the_vi_Editor]] is a good resource for an introduction.%0a%0a!! Starting Vi%0a[@vi [[files to edit]]@]%0a%0aExamples:%0a* Without any arguments, [@ vi @] will just start a blank new file.%0a* [@ vi a.txt @] will open [@ vi @] with the file [@ a.txt @]%0a%0a%0a!! Insertion Mode%0aIn insert mode, you can type in text%0a%0a[@ i @] switches to insert mode and [@ a @] switches to insert mode moving the%0acursor one character forward.%0a%0a[@ %3cEscape> @] can be used to exit insert mode.%0a%0a%0a!! Command Mode%0aCommand mode is used to send commands to the text editor. User [@ : @] to enter command mode.%0a%0a!!! Saving and Opening Files%0a[@ :w @] saves a files%0a%0a[@ :w [filename] @] Saves the file as [@ filename @]%0a%0a[@ :q @] exits the editor%0a%0a[@ :wq @] saves and exits%0a%0a[@ :q! @] exits without saving%0a%0a[@ :e [filename] @] opens file [@ filename @] for editing%0a%0a[@ :e! [filename] @] discards changes in current buffer and opens file [@ filename @] for editing%0a%0a!! Normal Mode%0aBy default [@ vi @], opens in Normal Mode.%0aNormal Mode allows you to cut, copy, paste, etc.%0aTo come back to Normal Mode from any mode, press [@ Escape @].%0a%0a[@ [num]command @] will execute [@ command @] [@ num @] times.%0a%0a!!! Movement%0aVi uses [@ h, j, k, l @] for movement.%0aIt allows for faster editing as the keys are present in the home row.%0a* [@ h @] moves one character left%0a* [@ j @] moves one line down%0a* [@ k @] moves one line up%0a* [@ l @] moves one character right%0a[@%0a k (up)%0a h (left) l (right)%0a j (down)%0a@]%0a%0a[@ w @] moves to the beginning of the next word while%0a[@ b @] moves to beginning of the previous word.%0a%0a[@ e @] moves to the end of the next word.%0a%0a[@ 0 @] moves to the beginning of the sentence while [@ $ @] moves to the end%0aof the sentence.%0a%0a[@ G @] moves to the end of the file%0a%0a[@ [num]G @] moves to the line number [@ num @]%0a%0aExamples:%0a* Initial%0a[@Hello! I like Vi.%0a^@]%0a* [@ w @] will move one word forward to [@ ! @]%0a[@Hello! I like Vi.%0a ^@]%0a* [@ 2w @] will move two words forward to [@ l @]%0a[@Hello! I like Vi.%0a ^@]%0a* [@ e @] will move to the end of the word%0a[@Hello! I like Vi.%0a ^@]%0a* [@ $ @] will move to the end of the line.%0a[@Hello! I like Vi.%0a ^@]%0a* [@ 3b @] will move three words back%0a[@Hello! I like Vi.%0a ^@]%0a* [@ 0 @] will move to the beginning of the line%0a[@Hello! I like Vi.%0a^@]%0a%0a!!! Cutting and Pasting%0a[@ yw @] copies a word, [@ yy @] or [@ Y @] copies a line.%0a%0a[@ dw @] cuts/deletes a word, [@ dd @] cuts a line, [@ D @] cuts a line from the cursor till the end (same as [@ d$ @]).%0a%0a[@ cw @] changes a word, [@ cc @] changes a line, [@ C @] changes a line from the cursor till the end (same as [@ c$ @]).%0a%0a[@ y, d and c @] can be combined with $0, $, f, t, etc.$%0a%0a[@ p @] is used to paste after the cursor while [@ P @] is used to paste before%0athe cursor.%0a%0a!!! Searching%0a[@ / @] is used to search forwards.%0a%0a[@ ? @] is used to search backwards.%0a%0a[@ n @] goes to the next occurrence while [@ N @] goes to the previous occurrence.%0a%0a[@ f[char] @] goes to the first occurrence (after the cursor) of [@char@]. [@ F[char] @] does the same thing but backwards.%0a%0a[@ t[char] @] goes to the position just before the first occurrence (after the cursor) of [@char@]. [@ T[char] @] does the same thing but backwards.%0a%0aExamples:%0a* Initial%0a[@Hello! I like Vi.%0a^@]%0a* [@fl@] goes to the third character in the line%0a[@Hello! I like Vi.%0a ^@]%0a* [@tI@] goes to the seventh character in the line%0a[@Hello! I like Vi.%0a ^@]%0a* [@Fl@] goes to the fourth character in the line%0a[@Hello! I like Vi.%0a ^@]%0a* [@TH@] goes to the second character in the line because [@ e @] is the character just before [@ H @] backwards.%0a[@Hello! I like Vi.%0a ^@] time=1645978593 title=Vi Introduction author:1645978593=Limits csum:1645978593=Add Introduction to Vi diff:1645978593:1645978593:=1,135d0%0a%3c (:title Vi Introduction:)%0a%3c %0a%3c Vi is the free and open-source editor that is present on most UNIX systems.%0a%3c Vi is a modal editor. It has three main modes (ways to interact with the editor).%0a%3c [[https://en.m.wikibooks.org/wiki/Learning_the_vi_Editor]] is a good resource for an introduction.%0a%3c %0a%3c !! Starting Vi%0a%3c [@vi [[files to edit]]@]%0a%3c %0a%3c Examples:%0a%3c * Without any arguments, [@ vi @] will just start a blank new file.%0a%3c * [@ vi a.txt @] will open [@ vi @] with the file [@ a.txt @]%0a%3c %0a%3c %0a%3c !! Insertion Mode%0a%3c In insert mode, you can type in text%0a%3c %0a%3c [@ i @] switches to insert mode and [@ a @] switches to insert mode moving the%0a%3c cursor one character forward.%0a%3c %0a%3c [@ %3cEscape> @] can be used to exit insert mode.%0a%3c %0a%3c %0a%3c !! Command Mode%0a%3c Command mode is used to send commands to the text editor. User [@ : @] to enter command mode.%0a%3c %0a%3c !!! Saving and Opening Files%0a%3c [@ :w @] saves a files%0a%3c %0a%3c [@ :w [filename] @] Saves the file as [@ filename @]%0a%3c %0a%3c [@ :q @] exits the editor%0a%3c %0a%3c [@ :wq @] saves and exits%0a%3c %0a%3c [@ :q! @] exits without saving%0a%3c %0a%3c [@ :e [filename] @] opens file [@ filename @] for editing%0a%3c %0a%3c [@ :e! [filename] @] discards changes in current buffer and opens file [@ filename @] for editing%0a%3c %0a%3c !! Normal Mode%0a%3c By default [@ vi @], opens in Normal Mode.%0a%3c Normal Mode allows you to cut, copy, paste, etc.%0a%3c To come back to Normal Mode from any mode, press [@ Escape @].%0a%3c %0a%3c [@ [num]command @] will execute [@ command @] [@ num @] times.%0a%3c %0a%3c !!! Movement%0a%3c Vi uses [@ h, j, k, l @] for movement.%0a%3c It allows for faster editing as the keys are present in the home row.%0a%3c * [@ h @] moves one character left%0a%3c * [@ j @] moves one line down%0a%3c * [@ k @] moves one line up%0a%3c * [@ l @] moves one character right%0a%3c [@%0a%3c k (up)%0a%3c h (left) l (right)%0a%3c j (down)%0a%3c @]%0a%3c %0a%3c [@ w @] moves to the beginning of the next word while%0a%3c [@ b @] moves to beginning of the previous word.%0a%3c %0a%3c [@ e @] moves to the end of the next word.%0a%3c %0a%3c [@ 0 @] moves to the beginning of the sentence while [@ $ @] moves to the end%0a%3c of the sentence.%0a%3c %0a%3c [@ G @] moves to the end of the file%0a%3c %0a%3c [@ [num]G @] moves to the line number [@ num @]%0a%3c %0a%3c Examples:%0a%3c * Initial%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ w @] will move one word forward to [@ ! @]%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ 2w @] will move two words forward to [@ l @]%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ e @] will move to the end of the word%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ $ @] will move to the end of the line.%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ 3b @] will move three words back%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@ 0 @] will move to the beginning of the line%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c %0a%3c !!! Cutting and Pasting%0a%3c [@ yw @] copies a word, [@ yy @] or [@ Y @] copies a line.%0a%3c %0a%3c [@ dw @] cuts/deletes a word, [@ dd @] cuts a line, [@ D @] cuts a line from the cursor till the end (same as [@ d$ @]).%0a%3c %0a%3c [@ cw @] changes a word, [@ cc @] changes a line, [@ C @] changes a line from the cursor till the end (same as [@ c$ @]).%0a%3c %0a%3c [@ y, d and c @] can be combined with $0, $, f, t, etc.$%0a%3c %0a%3c [@ p @] is used to paste after the cursor while [@ P @] is used to paste before%0a%3c the cursor.%0a%3c %0a%3c !!! Searching%0a%3c [@ / @] is used to search forwards.%0a%3c %0a%3c [@ ? @] is used to search backwards.%0a%3c %0a%3c [@ n @] goes to the next occurrence while [@ N @] goes to the previous occurrence.%0a%3c %0a%3c [@ f[char] @] goes to the first occurrence (after the cursor) of [@char@]. [@ F[char] @] does the same thing but backwards.%0a%3c %0a%3c [@ t[char] @] goes to the position just before the first occurrence (after the cursor) of [@char@]. [@ T[char] @] does the same thing but backwards.%0a%3c %0a%3c Examples:%0a%3c * Initial%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@fl@] goes to the third character in the line%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@tI@] goes to the seventh character in the line%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@Fl@] goes to the fourth character in the line%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a%3c * [@TH@] goes to the second character in the line because [@ e @] is the character just before [@ H @] backwards.%0a%3c [@Hello! I like Vi.%0a%3c ^@]%0a\ No newline at end of file%0a host:1645978593=2409:4060:18:a55b:cb97:acd0:80cb:9543