Blame
Date:
Sun Nov 27 05:00:19 2022
UTC
Message:
Daily backup
11
2022-04-02
text=(:title Vi Introduction:)%0a%0aPlease see [[unix101/unix101|unix101 tutorial]]. Or visit [[vi/intro|vi intro]].%0a
15
2022-04-02
diff:1645992993:1645977619:=3c3,135%0a%3c Please see [[unix101/unix101|unix101 tutorial]]. Or visit [[vi/intro|vi intro]].%0a---%0a> Vi is the free and open-source editor that is present on most UNIX systems.%0a> Vi 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> %0a> Examples:%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%0a> In insert mode, you can type in text%0a> %0a> [@ i @] switches to insert mode and [@ a @] switches to insert mode moving the%0a> cursor one character forward.%0a> %0a> [@ %3cEscape> @] can be used to exit insert mode.%0a> %0a> %0a> !! Command Mode%0a> Command 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%0a> By default [@ vi @], opens in Normal Mode.%0a> Normal Mode allows you to cut, copy, paste, etc.%0a> To come back to Normal Mode from any mode, press [@ Escape @].%0a> %0a> [@ [num]command @] will execute [@ command @] [@ num @] times.%0a> %0a> !!! Movement%0a> Vi uses [@ h, j, k, l @] for movement.%0a> It 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%0a> of the sentence.%0a> %0a> [@ G @] moves to the end of the file%0a> %0a> [@ [num]G @] moves to the line number [@ num @]%0a> %0a> Examples:%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%0a> the 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> %0a> Examples:%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> ^@]%0a\ No newline at end of file%0a
18
2022-04-02
csum:1645977619=Added https://en.m.wikibooks.org/wiki/Learning_the_vi_Editor as suggested by jan6
19
2022-04-02
diff:1645977619:1645969397:minor=5d4%0a%3c [[https://en.m.wikibooks.org/wiki/Learning_the_vi_Editor]] is a good resource for an introduction.%0a
23
2022-04-02
diff:1645969397:1645969397:=1,134d0%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 %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