LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Blogs > arniekat
User Name
Password

Notices



Rate this Entry

Slackware-13.37-Hacks-Vim Tutorial

Posted 02-03-2012 at 08:46 PM by arniekat

SOURCE - The Vimbook Tutorial Version 5.7 and Vim Manpages and vim.org

Elvis is a clone of the ex/vi text editor.
/usr/bin/vi is a symlink to elvis
Elvis is part of the package elvis-2.2_0

This tutorial, however will use Vim.
Vim is part of the package vim-7.3.154
Main Website: http://www.vim.org/
NOTE - vipw is an editor for the file /etc/passwd
vigr is an editor for the file /etc/group
visudo is an editor for the file /etc/sudoers
These special versions of vi are configured to lock the file being edited so there cannot be multiple simultaneous edits and they provide basic syntax checks.

BASIC 10 VIM COMMANDS

The Vimbook from the website has a tutorial for the 10 Basic Commands, which are all you really need to basically edit files in Slackware. I show below some of the information from that tutorial which should take care of your editing needs. If you ever get into trouble, hit the <Esc> key twice and you will be in command mode.

1. The four basic movement commands

When you are in command mode, you can move around by using these keys:

h (left) or ARROW-LEFT
j (down) or ARROW-DOWN
k (up) or ARROW-UP
l (right) or ARROW-RIGHT

I usually use the arrow keys, however it is a good idea to learn the other keys in case you get a keyboard with no arrow keys or arrow keys in a strange location.

2. Insert And Delete Text

Inserting Text

To enter text, you need to be in insert mode. Type i, and notice that the lower left of the screen changes to --INSERT-- (meaning that you are in insert mode). Now type your text.

After you have finished inserting, press the <Esc> key. The --INSERT-- indicator goes away and you return to command mode.

Deleting Text

If you want to delete text, just move the cursor over the it and type x. Continue typing x to delete individual characters. To delete a whole line, place the cursor on the line you want to delete. Type dd to delete the line and vim will delete the line and take up the empty space.

3. Undo and Re-Do

The u command undoes the last edit and CTRL-R undoes the undo.

4. How to get Help

In command mode type :help <ENTER> to get help.
To get out of help type :q! <ENTER> and you will be back at your document.

5. Exiting the editor

To exit the editor without saving your changes type :q! <ENTER> (A colon, the letter q, and an exclamation point)
To write the changes to the file and exit type :wq <ENTER> (A colon, the letter w, and the letter q)

ENCRYPTING TEXT

When you wish to create an encrypted file, you will enter the command shown below on the Terminal. The -n flag suppresses the swap file so recovery after a crash will be impossible. The -x flag tells vim to use encryption when writing files. You will be prompted for the password.

$ vim -nx /home/<user>/file.txt
Enter encryption key: <Password> ENTER
Enter same key again: <Password> ENTER

If you use a Hex Editor to open up the encrypted file, it will have this as a header:

VimCrypt~01!

and then garbage.
Posted in Uncategorized
Views 879 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement

Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration