[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
slackbook:vi [2012/09/02 12:43 (UTC)] – [Sources] Changed anchor. alienbobslackbook:vi [2012/09/12 21:49 (UTC)] – [The Different Modes of vi] Updated with original text and formatting mfillpot
Line 4: Line 4:
  
  
-Scattered all around your computer are thousands of text files. To a new user, this may seem inconsequential, but almost everything in Slackware Linux uses a plain-text file for configuration. This allows users to make changes to the system quickly, easily, and intuitively. In the [[slackbook:bash|bash]] chapter, we looked at a few commands such as cat and less that can be used to read these files, but what if we want to make changes to them? For that, we need a text editor, and vi is up to the task.+Scattered all around your computer are thousands of text files. To a 
 +new user, this may seem inconsequential, but almost everything in 
 +Slackware Linux uses a plain-text file for configuration. This allows 
 +users to make changes to the system quickly, easily, and intuitively. 
 +In chapter 5, we looked at a few commands such as 
 +**//cat//** and **//less//** that 
 +can be used to read these files, but what if we want to make changes to 
 +them? For that, we need a text editor, and 
 +**//vi//** is up to the task.
  
-In short, vi is one of the oldest and most powerful text editors still used today. It's beloved by system administrators, programmers, hobbyists, and others the world over. In fact, nearly this entire book was written using vi; only the next chapter on emacs was written with that editor. 
  
-A little further explanation is needed to learn exactly what vi is today though, as Slackware Linux technically doesn't include vi. RatherSlackware includes two vi "clones", elvis(1) and vim(1). These clones add many additional features to vi such as syntax highlightingbinary editing modes, and network supportWe won't go too deeply into all these details. By defaultif you execute vi on Slackware Linux, you'll be using elvis, so all examples in this chapter will assume that is what you are using. If you've used another Linux distribution before, you may be more familiar with vim. If so, you might wish to change the symlink for /usr/bin/vi to point to /usr/bin/vim, or add an alias to your shell's startup scripts. vim is generally considered to be more feature-rich than elvis, but elvis is a much smaller program and contains more features than most users will ever need.+In short, **//vi//** is one of the oldest and most 
 +powerful text editors still used today. It's beloved by system 
 +administratorsprogrammershobbiests, and others the world overIn 
 +factnearly this entire book was written using 
 +**//vi//**; only the next chapter on 
 +**//emacs//** was written with that editor.
  
-vi is very powerful, but also somewhat cumbersome and challenging for a new user to learn. However, mastering vi is an important skill for any self-respecting system administrator to learn, as vi is included on nearly every Linux distribution, every BSD system, and every UNIX system in existence. It's even included in Mac OS X. Once you've learned vi, you'll not have to learn another text editor to work on any of these systems. In fact, vi clones have even been ported to Microsoft Windows systems, so you can use it there too. 
  
 +A little further explanation is needed to learn exactly what
 +**//vi//** is today though, as Slackware Linux
 +technically doesn't include **//vi//**. Rather,
 +Slackware includes two vi //"clones"//, **//elvis//**(1)
 +and **//vim//**(1). These clones add many additional
 +features to vi such as syntax highlighting, binary editing modes, and
 +network support. We won't go too deeply into all these details. By
 +default, if you execute **//vi//** on Slackware
 +Linux, you'll be using **//elvis//**, so all
 +examples in this chapter will assume that is what you are using. If
 +you've used another Linux distribution before, you may be more familiar
 +with **//vim//**. If so, you might wish to change
 +the symlink for ''/usr/bin/vi'' to point to
 +''/usr/bin/vim'', or add an alias to your shell's
 +startup scripts. **//vim//** is generally considered
 +to be more feature-rich than **//elvis//**, but
 +**//elvis//** is a much smaller program and contains
 +more features than most users will ever need.
 +
 +
 +**//vi//** is very powerful, but also somewhat
 +cumbersome and challening for a new user to learn. However, mastering 
 +**//vi//** is an important skill for any
 +self-respecting system administrator to learn, as 
 +**//vi//** is included on nearly every Linux
 +distribution, every BSD system, and every UNIX system in existance. 
 +It's even included in Mac OS X.
 +Once you've learned **//vi//**, you'll not have to
 +learn another text editor to work on any of these systems. In fact,
 +**//vi//** clones have even been ported to Microsoft Windows
 +systems, so you can use it there too.
 ===== The Different Modes of vi ===== ===== The Different Modes of vi =====
  
-New users are often frustrated when using vi for the first time. When invoked without any arguments, vi will display a screen something like this.+New users are often frustrated when using **//vi//** 
 +for the first time. When invoked without any arguments,  
 +**//vi//** will display a screen something like 
 +this. 
 + 
 + 
 +<code>
  
-<code>~ 
 ~ ~
 ~ ~
Line 27: Line 74:
 ~ ~
 ~ ~
-                                     Command</code>+
 +                                     Command 
 +</code>
  
-At this point, the user will begin typing and expect the keys pressed to appear in the document. Instead, something really strange happens. The reason for this is simple. vi has different operation "modes". There is a command mode and an insert mode. Command mode is the default; in this mode, each keystroke performs a particular action such as moving the cursor around, deleting text, yanking (copying) text, searching, etc. 
  
 +At this point, the user will being typing and expect the keys he
 +presses to appear in the document. Instead, something really strange
 +happens. The reason for this is simple. **//vi//**
 +has different operation //"modes"//. There is a command mode and an insert
 +mode. Command mode is the default; in this mode, each keystroke
 +performs a particular action such as moving the cursor around, deleting
 +text, yanking (copying) text, searching, etc.
 ===== Opening, Saving, and Quitting ===== ===== Opening, Saving, and Quitting =====
  
Line 88: Line 143:
 |:x|Save and quit| |:x|Save and quit|
  
-=====Sources=====+====== Chapter Navigation ====== 
 + 
 +**Previous Chapter: [[slackbook:working_with_filesystems|Working with Filesystems]]** 
 + 
 +**Next Chapter: [[slackbook:emacs|Emacs]]** 
 +======Sources======
  
- * Original source: http://slackbook.org/beta/#id363493 (authors: Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson)+  * Original source: http://slackbook.org/beta/#id331567 (authors: Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson)
 slackbook:vi ()