VIM Snippets and Resources

Sometimes you have to get yourself to use VIM. It is a good tool, but when you are starting out, it can be frustrating. Come here for some links to resources and useful snippets; it’s cheaper than a therapist. I need these for myself also.

Snippets

Clear Last Search Pattern

:let @/=””

or

:noh

Repeat Character N Times

:norm 79i=

Stop Recording
Sometimes I don’t know how I got here but I gotta get out!!!

q

Open File Under Cursor
I found out about this at http://vim.wikia.com/wiki/Open_file_under_cursor

gf

Export File To Syntax Highlighted HTML

:runtime! syntax/2html.vim

Reformat XML File
I got this from:
http://stackoverflow.com/questions/7600860/getting-vim-to-recognize-xml

I just put this here to make it easy to get do. First and foremost:

:setsyntax=xml
:set indentexpr=XmlIndentGet(v:lnum,1)

If you have a 1-line file:

:%s/\(<[^>]*>\)/\1\r/g

Then a gg=G does the magic.

Useful Links

Nothing like going to the source itself: www.vim.org
A good source for tips: http://vim.wikia.com/

Cheat Sheets

Nice and clean, not a lot of cryptic graphics: tnerual.eriogerg.free.fr/vimqrc.html
Some good notes: http://www.brezeale.com/technical_notes/vim_notes.shtml
vim and Tabs

https://www.linux.com/learn/tutorials/442422-vim-tips-using-tabs

Useful .vimrc settings

set backupdir = ~/tmp # annoying ~ files in ~/tmp
set noswapfile #no swap files
#set nobackup #uncomment out for no backups, period
#set nowritebackup #no backup files while editing

This entry was posted in Snippets and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *