Jul 162007
My first computer job 18 years ago me access to my first Unix system. The people knew with Unix accounts and the CS classes I took all used Emacs as their prefered text editor. Due to that, I developed a strong preference for the emacs editor over vi. To this day I only know the very basic commands of vi/vim.
For the next two weeks I’m going to put serious effort in learning vi/vim. I’m going to alias emacs and gedit to launch vim, and try to do as much work in vim as I can.
Two questions I have:
- On my Ubuntu machine, should I install any other vim packages to get better functionality. As of now I only have vim-tiny installed. I would like to get syntax highlighting with vim if possible.
- Could someone point me to a good vi/vim cheat sheet or guide with the commands I need to learn
I will report back in two weeks and let people know how it goes.
25 Responses to “vi: Teaching an old tech new tricks”
Sorry, the comment form is closed at this time.




1. sudo apt-get install vim-common
vim /etc/vim/vimrc
and remove the leading ” for ‘syntax on’
2. try this: http://cheat-sheet.de/wp-content/uploads/cheat-sheet_de/vi-cheat-sheet.pdf
I tend to install the vim-full package:
apt-get install vim-pull
Syntax highlighting:
:syntax on
My config:
http://www.jukie.net/~bart/conf/vimrc
http://www.jukie.net/~bart/conf/vim
….this is about a decade of accumulated crud
err, that’s:
apt-get install vim-full
err, that’s:
apt-get install vim-full
I would suggest get comfortable with the basics first…
Quit – :q
Force-quit (e.g. if you’ve already modified a file) – :q!
Write – :w
Write, then Quit – :wq
Left/Down/Up/Right – h/j/k/l
Go to line 5 – 5G
Go to the end of the file – 0G
Delete/cut a line – dd
Yank (copy) a line – yy
Delete/cut a word – dw
Yank a word – yw
Searching – /
Change into visual (selection) mode – v
Sorry if you already know all this…
Kris
Bartman: try again…
sudo apt-get install vim-full vim-python vim-perl
open up ~/.exrc in something like vi or gedit and add this line:
syn on
Save the file and start vi, syntax highlighting will always be enabled now. If you don’t like that,
:syn off
will turn it off on a per instance basis
I use vim-full also. And since my terminal background is black, I use
set background=dark
syntax on
This makes the colors brighter, and way easier to see.
juste type “vimtutor” in a shell when you have 5 minutes to lose and enjoy
here is a good cheat sheet which helped me much
http://tnerual.eriogerg.free.fr/vimqrc.pdf
Here are a few links to tutorials I’ve done on vim.
http://tinyurl.com/2op95p
http://tinyurl.com/2m3ohm
http://tinyurl.com/36qa49
http://tinyurl.com/37f69z
good luck, it’s worth the learning curve!
Cream.
I love Cream. It’s VI for GUI babies like me.
vimtutor is very nice to start with.
for the cheat sheet, see the vim mug. It seems like a good companion.
http://nostarch.com/frameset.php?startat=mug_big
A great cheat sheet – based on the keyboard – is available from http://www.viemu.com/ – the full version is http://www.viemu.com/vi-vim-cheat-sheet.gif and there are focussed versions for particular tasks.
And I will add my voice to those suggesting vimtutor as a good way to get started.
Hey, as to a cheat sheet, check out http://tnerual.eriogerg.free.fr/vim.html It is available in several different languages. This is one that I actually printed out on both sides and laminated – it sits by my keyboard all the time. It’s more a ‘quick reference’ though as it has many commands (some you may not use at first). Hope this helps out.
[...] Link to Article linux vi: Teaching an old tech new tricks » Posted [...]
Personally, I’m not a fan of gvim or cream. I would suggest ‘apt-get install vim’ which installs everything, I want, syntax and coloring and all that, without gvim. Vim is all about the little commands you pick up over long periods of time, which make moving around and manipulating text more flexible (but it does take a long time to pick it all up and get used to it). As for my .vimrc: syntax on, set ruler autoindent smartindent
My favorite tutorial:
http://www.vi-improved.org/tutorial.php
The University of Hawaii has a nice cheet sheet at the bottom of it’s tutor: http://www.eng.hawaii.edu/Tutor/vi.html
Checkout the vimtips: over 1500 Tips since 2/2001
Also search the archive of vim@vim.org on mail-archive.org. Subscribe to vim-experiment@googlegroups.com . There is a very friendly and helpful community even for newbies. vimtutor has been mentioned. Learn to use the :help. Take your time. You need at least a year to get comfortable with vim. Rumours say that you own the editor if you know what typing your name would do in vim. There are a lot of cool scripts that are not enabled by default search them in the vim runtime. shit batteries empty. …
now…
Ive assembled a reference card that maps ideas to cryptic commands, not the other way round as you’ll find many more. Find mine here: http://simpletutorials.com/html/vim/vimquick.pdf. If you fill out a lot of web forms, try out the “It’s all text” plugin for firefox. (also works for emacs, but i guess it’s slower
)
The link to the vim tips is here: http://vim.wikia.com
Two more tips:
* learn the concepts of vim, not stupid commands like “ZZ” or “wq”. The “modes” and extensibility is what makes vim special.
* Search for the “7 habits of text editing” of bram. quite useful, and mainly independent of the editor …
I think thats all. Vim rocks!
Sebastian.
I learned most of the cool things by reading the online :help, back when I still had lots of spare time.
Most useful advanced vim features for me are:
– word completion (^P/^N in insert mode)
– window splits (^W s, ^W v)
– jumping to class/function definitions (^] after building a tags file with :!ctags -R .)
– jumping to filename under cursor (gf)
– interactive diffs (vimdiff file1 file2)
I also quite like the high-level editing commands (e.g. “change the contents of the current HTML element to something else” -> citsomething else).
Also check http://vim.wikia.com/wiki/Category:VimTip
Too many VI cheat sheets want you to memorize what appears to be random gibberish.
The truth is that there is a structure to the VI command set. I have linked my name (above) to the list of cheat sheets that I make available to my students (and the rest of the ‘net, of course!). Please forgive the rather hokey layout; I’ll change that one of these days… In the meantime, if you scroll down towards the bottom you’ll find a link to the VI cheat sheet. In summary, the cheat sheet shows that you can take “one from column A and one from column B” to create most VI commands. There are a few exceptions and the common ones are right smack in the middle of the first page of the cheat sheet.
Hope that helps.
As for extra packages, you might needs ctags if you don’t have it. Other than that I can’t think of anything.
Look for some sample .vimrc’s on the web if you have time. You’ll find many definitions and macros that save a lot of time and trouble. You can reuse the ones that you think are useful to you instead of reinventing them.
Software Development Guide…
I couldn’t understand some parts of this article, but it sounds interesting…