Updated: April 23rd, 2008
[WORK IN PROGRESS] Here is a list of commands that I use every day with vim, in no particular order. Out of a billion possible key combinations, I found these to be irreplaceable and simple enough to remember.
|
* |
search for the word under cursor (to the end of the file) |
|
# |
search for the word under cursor (to the top of the file) |
|
ctrl-p,ctrl-n |
suggest (p)revious or (n)ext autocomplete from the list of existing keywords in the file or included files (!). |
|
:go NNN |
go to byte NNN |
|
. |
redo last command |
|
/SEARCH TERM |
search document for SEARCH TERM |
|
:%s/FOO/BAR/gci |
replace FOO with BAR (g)lobally, case (i)insensitively, and asking for (c)onfirmation |
…
Updated: July 8th, 2009
Today I was asked a question about defining custom extensions for vim syntax highlighting such that, for example, vim would know that example.lmx is actually of type xml and apply xml syntax highlighting to it. I know vim already automatically does it not just based on extension but by looking for certain strings inside the text, like <?xml but what if my file doesn't have such strings?
After digging around I found the solution. Add the following to ~/.vimrc (the vim configuration file):
1 2 3 |
syntax on filetype on au BufNewFile,BufRead *.lmx set filetype=xml |
After applying it, my .lmx file is highlighted:
Same principle works, for instance, for mysql dumps that I have to do from time to time. …
beer planet is a blog about technology, programming, computers, and geek life. It is run by Artem Russakovskii - a local San Francisco geek who is currently pursuing his own projects and regularly enjoys hacking Android, PHP, CSS, Javascript, AJAX, Perl, and regular expressions, working on Wordpress plugins and tools, tweaking MySQL queries and server settings, administering Linux machines, blogging, learning new things, and other geeky stuff.