Posts

Showing posts with the label vim

vim productive note

When writing tests for Perl objects (or modules), I like to store the name of the module in a named buffer/register in vim. I usually visually highlight the object(or module) name, then put it in the "n" buffer. Yank into n: "ny Paste out of n: "np I guess the m or n buffer might make sense. If you forget like I do what buffer your using you can dump them in vim with: registers So it was...

Building vim on os x 10.5

I like to build my own version of vim on systems. This usually avoids any problems later when I want to add something new in to it or upgrade to a newer version. In the past older versions of OS X (10.4 and 10.3 ) I could just build vim straight but on 10.5 I had a strange issue of it starting up X11 when I ran it in my terminal window. It seems that either vim or OS X became smarter when it came to talking between process using X Windows communication protocol. (XSMP) Just adding a --without-x to the configure statement didn't help. It required disabling the XSMP protocol. Here is the configure line: ./configure --without-x --disable-xsmp Much better, now I just need to figure out the best terminal font for my 24" iMac. :)

vim - insert current filename

When writing comments in source code or for some other reason than I can think of right now, I like to include the current filename into current vim session. How? Enter insert mode use following key sequence: ctrl-r % POOF! You have the filename (it does include the path). In vim % is the current filename. It is very useful when writing mappings or running commands from the : prompt.

vim makes me pasty when pasting

For a while its bugged me that when I paste into a vim session with all nice options turned on, it formats the crap out of it. At some point setting set noautoindent stopped fixing this problem. Thank goodness that I found a solution, it probably exists for years but with vim sometimes knowing the right verbage is the key to a finding how to do it. (its probably been there since version 5.0) Here is how it works for me: pre paste - :set paste paste in code/snippet/sql/guinea pig :set nopaste Man that makes my life so much easier...

Vim, Tidy and XML - how to make them work together

Background I use vim as my main IDE. I found that I often have to muck and view XML. Often this XML is from debugging logs or output that don't add whitespace (and why would they). The following is my setup for a small vim filetype mapping to automatically clean up xml using HTML tidy . Another great tool. How To First, You'll need $HOME/.vim and $HOME/.vim/ftplugin directories. Create them, if they don't exist: mkdir -p $HOME/.vim/ftplugin Second, create a new ftplugin for xml. vim $HOME/.vim/ftplugin/xml.vim Third, add mapping for tidy (I use F3) " tidy for xml -q makes it quiet map <F3> :%! tidy -q -i -xml % <CR> Now when you edit a file with a type of xml, you can press F3 your xml will be tidy'd. This does require that you save the xml file somewhere first (you'll need a valid filename). Caveats I've only used this on UN*Xs OSs I use vim 7.x, it will probably work on 6 I enable filetype support in my .vimrc with command filetyp...