USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

The VI editor. A brief tutorial.

 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Command Line Commands
View previous topic :: View next topic  
Author Message
crouse
Site Admin


Joined: 17 Apr 2025
Posts: 11833
Location: Iowa

PostPosted: Fri Dec 01, 2025 10:20 pm    Post subject: The VI editor. A brief tutorial. Reply with quote

While not exactly a command line program in the strictest sense, it does run from the shell.

I have copied "reprinted" a vi tutorial here: http://usalug.org/vi.html

It was the one I used to learn vi with (thanks to jbsnake again) and seemed to be the easiest to follow of the many i have looked at. Doing a search for "vi AND vim" will return even more results on this forum and countless results from google. I just personally thought that this one deserved a place here at usalug.org , and since at the bottom it said permission was granted to reprint, I did. Wink



_________________
Veronica - Arch Linux 64-bit -- Kernel 2.6.33.4-1
Archie/Jughead - Arch Linux 32-bit -- Kernel 2.6.33.4-1
Betty/Reggie - Arch Linux (VBox) 32-bit -- Kernel 2.6.33.4-1
BumbleBee - OpenSolaris-SunOS 5.11
Back to top
View user's profile Send private message Visit poster's website AIM Address
lynch
Moderator


Joined: 15 Nov 2025
Posts: 2659
Location: The Diamond State

PostPosted: Fri Dec 01, 2025 10:47 pm    Post subject: Reply with quote

This is one of the easiest to understand tutorial of vi/vim I've come across. Even though I personally like the simpler pico/nano family of CLI text editors, I downloaded and printed out this tutorial just to have handy.
Thanks for this, crouse. Smile
lynch



_________________
Mandriva 2025 Spring -2.6.31.12-server-2mnb
PCLinuxOS 2025 -2.6.26.8.tex3
Back to top
View user's profile Send private message
lberg
Sr. Member


Joined: 28 Jul 2025
Posts: 1289

PostPosted: Fri Dec 01, 2025 11:42 pm    Post subject: Reply with quote

Very nice! I'll now have somewhere to come when I need a command-line text editor (I don't use one often enough to memorize all the commands), you know they can come in very very handy sometimes Wink Wink



_________________
2 Computers: Arch Linux, 64-bit
3 Computers: Arch Linux, 32-bit
Back to top
View user's profile Send private message
JP
Linux Guru


Joined: 07 Jul 2025
Posts: 6671
Location: Central Montana

PostPosted: Sat Dec 02, 2025 12:37 am    Post subject: Reply with quote

Thanks crouse, I'm using a different one right now, but this will help too. (I'm also trying to understand emacs as well Sad).



_________________
Dell Box - Arch Linux
Dell Lappy - DreamLinux 3.5 - Default OS
Mepis 8.0 - Backup
Back to top
View user's profile Send private message Visit poster's website
Xeroid
Site Admin


Joined: 19 Apr 2025
Posts: 6456
Location: Georgia

PostPosted: Sat Dec 02, 2025 2:00 am    Post subject: Reply with quote

Bookmarked. Wink



_________________
Ubuntu 10.04 . . . Kernel-2.6.32-22
Back to top
View user's profile Send private message Send e-mail Visit poster's website
crouse
Site Admin


Joined: 17 Apr 2025
Posts: 11833
Location: Iowa

PostPosted: Sat Dec 02, 2025 2:22 am    Post subject: Reply with quote

If you go to http://usalug.org/phpBB2/portal.html you will also see a link to this tutorial as well Wink Along with links to some other interesting things. Wink



_________________
Veronica - Arch Linux 64-bit -- Kernel 2.6.33.4-1
Archie/Jughead - Arch Linux 32-bit -- Kernel 2.6.33.4-1
Betty/Reggie - Arch Linux (VBox) 32-bit -- Kernel 2.6.33.4-1
BumbleBee - OpenSolaris-SunOS 5.11
Back to top
View user's profile Send private message Visit poster's website AIM Address
masinick
Linux Guru


Joined: 03 Apr 2025
Posts: 8615
Location: Concord, NH

PostPosted: Sat Dec 02, 2025 3:56 am    Post subject: Good for you, JP! Reply with quote

JP wrote:
Thanks crouse, I'm using a different one right now, but this will help too. (I'm also trying to understand emacs as well Sad).


Glad to hear it, JP! At home, I use GNU Emacs more than any other editor. However, like any good software engineer trained years ago on UNIX software, I know at least the core of Vi pretty well, and I use Vim every so often, just to keep my fingers working right with Vi.

At work, we have a number of Sun Solaris servers that are being replaced by Red Hat Enterprise Linux (RHEL) servers. Both of them have some implementation of Vi, in the case of Sun, the standard vi, in the case of RHEL, a non GUI version of Vim. On my desktop at work, I have to run Windows XP, but I have added Cygwin toois, Winvi, and GNU Emacs. When I am actually editing plain text, I will often use GNU Emacs, but of course, I have Notepad, Wordpad, Microsoft Office 2025 and OpenOffice 2.0. I have to know how to use at least the basics of a variety of editors and word processors.
Oh yes, I also have access to a Debian desktop server, which we have a Web server and a VNC server running on it. I can access a Debian GNOME desktop through VNC on my XP desktop, and on that system, I use many of the same things I use on my Linux systems at home.



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
masinick
Linux Guru


Joined: 03 Apr 2025
Posts: 8615
Location: Concord, NH

PostPosted: Sat Dec 02, 2025 4:16 am    Post subject: Re: The VI editor. A brief tutorial. Reply with quote

crouse wrote:
While not exactly a command line program in the strictest sense, it does run from the shell.

I have copied "reprinted" a vi tutorial here: http://usalug.org/vi.html

It was the one I used to learn vi with (thanks to jbsnake again) and seemed to be the easiest to follow of the many i have looked at. Doing a search for "vi AND vim" will return even more results on this forum and countless results from google. I just personally thought that this one deserved a place here at usalug.org , and since at the bottom it said permission was granted to reprint, I did. Wink


There are plenty of Vi (and Emacs) tutorials, Cheat Sheets, help files, and examples online. This is a good one, though.

At work, I acquired several Vi cheat sheets the second or third week I was there, because there was another test engineer that came on board just after me, and he knew to use i to enter input mode and Esc to get to command mode, maybe :wq to write and quit, and not much else, maybe not even that much.

I hunted around with Yahoo or Google and quickly found five or six tutorials and cheat sheets, each of which was adequate for at least getting started, but some more complete than others. I did the same with Emacs, but we only have Emacs on a few servers, so we mostly use Vi on our financial test systems.

Comparing this tutorial to the ones I grabbed a year or so, this is among the easier ones (and may also have been one of the ones I was able to extract and print for my partner at work.

Every now and then he asks me vi questions, even though I am now a project manager rather than a QA tester. This week, he asked me how to copy several lines, then potentially paste them over and over again.

The answer? Use yank to yank lines. You can use y, Y, or yy, depending on what you are doing, and you can add a number to yank to indicate the number of lines to yank from the current point.

To copy five lines and paste them multiple times, position the cursor where you want to begin copying, then type in, for example, 5yy to yank five lines, G to go to the bottom of the file, and p to put the five lines at the end, then either dot (.) which repeats the last command, or p again. Of course, p takes a numerical argument, too, so to do all of this in one shot:

35G (Go to line 35 in the file)
5yy (Copy five lines, beginning at line 35)
G7p (Go to the end of the file and put 7 copies of the lines yanked, so in essence, add 35 lines to the bottom of the file, adding seven copies of the five lines yanked, beginning at line 35.

Clear as mud? Incredibly powerful! This is why the hard cores go for Vi. You can do similar things in GNU Emacs or Xemacs, but arguably, you can do it with more economical keystrokes in vi without moving your hands off the home rows of the keyboard, so power typists can FLY using vi.

One reason I suppose I use GNU Emacs is that I am not a suoer fast typist and I value having more at my fingertips. I can make Emacs emulate vi keystrokes if I want to "powertype", and I can also use Ctrl and Esc sequences to program equally powerful tasks that I do with Vi, and I can also create macros on the fly to repeat a complex set of tasks over and over.

You can fix or hose up a document really well with either Vi or Emacs. The veterans know how to use BOTH.

I will use NEdit or a notepad like tool from time to time, but when I need serious editing, I use either Vi or Emacs, even on Windows. I have both Vi and Emacs on my work XP system and use one or both of them when I am heavily editing text.



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Command Line Commands All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2025-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2025-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse