jay johnston dot com
mootools php faith camera linux

linux

Jay's .vimrc




syntax on
syntax enable
set noautoindent
map 
<F10odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map 
<F12odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
set ffs
=unix,dos


Syntax on is great for seeing your code highlighted. You can read more about syntax highlighting in vim.

I use noautoindent because I frequently copy and paste blocks of code. Yes, vim is great at keeping a buffer, but I've found that the rhythm of manually indenting works for me. If you find that you want to indent new lines by a similar amount to the one next to them, then use set autoindent instead.

I was introduced to map at ICGLink. This is a fantastic feature that lets one further extend and customize keyboard functionality in vim. My four entries do essentially the same ting. They all insert a debugger statement for an array in php. The ones with the exclamation point are necessary to make the insertion work both in and out of command mode. Insert mode will be entered (using the i at the end of the map sequence), preparing the user to enter the name of the array to be debugged. I have it mapped to F10 and F12 (partially cause I can't remember where I like it better).

Know anyone that is developing with you that uses a mac? Eegads when that ^M character line feed shows up, it's such a pain! You can set ffs=mac to view them more cleanly in vim. Beware, though, an unintended outcome is that the files YOU write will then be encoded that way; moreover, php will not parse the error message and the line on which it occurs properly when the encoding is set to mac. (The best bet is to clean the ^M using my mac encoding remover shell script.

Updated Version:

syntax on
syntax enable
set noautoindent
map 
<F10odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map 
<F12odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map 
<F6i<script type="text/javascript" language="javascript"> <CR>{literal}<CR>jujuscript<CR>{/literal} <CR></script><CR><ESC>?jujuscript<CR>cw
map! <F6> <script type="text/javascript" language="javascript"> <CR>{literal}<CR>jujuscript<CR>{/literal} <CR></script><CR><ESC>?jujuscript<CR>cw
set ffs=unix,dos


I frequently use smarty templating and have to type a javascript block in complete with the literal tags to delimit the curly braces. The  <F6 entries show how to do that much more quickly using vim's map functionality.

Updated Version:

set noautoindent
map 
<F10odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map 
<F12odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map
! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map 
<F6i<script type="text/javascript" language="javascript"><CR>{literal}<CR>jujuscript<CR>{/literal}<CR></script><CR><ESC>?jujuscript<CR>cw
map! <F6> <script type="text/javascript" language="javascript"><CR>{literal}<CR>jujuscript<CR>{/literal}<CR></script><CR><ESC>?jujuscript<CR>cw
map <F7> i<script type="text/javascript" language="javascript"><CR>{literal}<CR>jujuscript<CR>{/literal}<CR></script><CR><ESC>?jujuscript<CR>cw
map! <F7> <script type="text/javascript" language="javascript"><CR>{literal}<CR>jujuscript<CR>{/literal}<CR></script><CR><ESC>?jujuscript<CR>cw
let g:netrw_ftp_cmd="ftp -z nossl"
set ffs=unix,dos
map php :set syntax=php<CR>


I've added a map that let's me set the syntax coloring. If you open a file that is php but doesn't have php syntax, just type "php". map php :set syntax=php does the command and sets the syntax coloring correctly.

Last Updated: 2009-06-15 07:29:28

Creative Commons License Valid XHTML 1.0 Transitional Powered by PHP
Jay Johnston is a Zend Certified Engineer in PHP 5