s5h.net

“fresh linux news and advice.”

arrow Info

The linux news section is submitted by Roy Schestowitz, many thanks!

illustration

more here.

arrow Links


pucevim

One of the most important tools of a unix administrator is ability to use a text editor. Perhaps the most popular text editor available on unix systems is the vi improved editor, or simply vim.

Here is my cheat sheet. When I find useful commands that reduce the time that I spend editing files (which can be a day long process) I put things here so that I can remember them later. The functions here are what I find highly useful for good editing. Having the ability to reduce the work involved in making many changes at once is advantageous, so here is my over view of the things which I think benefit the most when using vim.

^c indicates a control character for letter c.

pucecommands

The commands that I think are perhaps the most important of are the following

command action/purpose
{,} moves to the beginning or end of paragraph at cursor
(,) moves to the beginning or end of sentence
m sets a bookmark in a-z and A-Z slots (help m)
' jumps to bookmark in slot a-z and A-Z (help m)
gg jumps to start of document
G or :$ jumps to end of document
:n jumps to line n
z= suggest spelling alternatives
*,# go to matching word under cursor. this is useful for jumping to a function that you're calling (* = forward, # = reverse )
gg=G apply tabulation rules to the current file
ga shows the hex, decimal and ordinal values of the character under cursor
ctrl-a/ctrl-x adds/subtracts to/from decimal under cursor
J joins this line in the next (keeps inserts a space character between join
^f, ^b go forward or backwards by a page
1,$!grep something run the grep command on the full buffer (1,$)


pucevisual mode



command action/purpose
ab/aB select () or {}
: perform operation on block
:'<,'>s/foo/bar/g perform regular expression subsitution on block
gu / gU switches the case of the visual block depending on the case of u
g? rot 13 the block
^v visual block selection, rather than selecting by line this will select by rectangle


puceconfig

The environment for vim that I find the most convenient can simply be stored in a text file in your home directory named ~/.vimrc.

command action/purpose
set spell enables spell checker, right click, or z= to suggest alternatives
set number show line numbers
set autoindent automatically tab on code blocks
set ts=8 sets the tab stops to 8 character spaces
set sw=8 sets the autowrap to 8 characters
syntax enable automatically highlight code keywords
set linebreak automatically wrap whole words. this can be used rather than set line width
set fileformat=dos/unix/mac sets the line breaks when saving


pucefor code



command action/purpose
]p paste, but indent at the same time
% go to matching (, {, [ etc
gd go to definition or declaration
K go to man page for the word under cursor
:mksession, vim -S Session.vim save session and open the saved session


pucevideo links

These pages contain links to various external sites that have vim videos. These videos are for educational purposes and might be live demonstrations or talks describing how vim works.

address description of content
http://danielwebb.us/software/vim_demo/ screen captures of performing regular vim work
http://www.youtube.com/watch?v=eScUUhCEPzs&NR=1 you tube video showing vi tp be suitable for editing python code (but it's code agnostic)
http://www.youtube.com/watch?v=IMC9PtXwCtI another example of vim in use
http://www.youtube.com/watch?v=eX9m3g5J-XA Bram Moolenaar talks about using vim effectively for text editing, or even how to use vim more effectively by people who use it extensively already
http://www.youtube.com/watch?v=30P8DSNOZuU demo of using vim and rails.vim to get writing pages quicky
http://www.youtube.com/watch?v=XSXoap2h3Mw vim editor tutorial (1)
http://www.youtube.com/watch?v=dsKGMxoydCc vim editor tutorial (2)


pucereference cards



Laurent Gregoire's refernce card
Donald J. Bindner's reference card
vim reference mug
guido's card
vimtips


Powered by WebRing.