linux
Jay's .vimrc
syntax on
syntax enable
set noautoindent
map <F10> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map <F12> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
set ffs=unix,dos
nmap ,cl :let @*=expand("%:p")<CR>
map php :set syntax=php<CR>
au BufWinLeave * mkview
au BufWinEnter * silent loadview
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 <F10> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map <F12> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map <F6> i<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 <F10> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F10> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map <F12> odie('<pre>'.print_r($,true));<ESC>?,true<CR>i
map! <F12> die('<pre>'.print_r($,true));<ESC>?,true<CR>i
map <F6> i<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.
Auto fold saving:
au BufWinLeave * mkview
au BufWinEnter * silent loadview
Read about vim folding.
Spaces not Tabs!
I'm working in a project where the tabs are out of control. It's easy to
, but that's not an option. So, to display the tabs as just 2 spaces and also to help me remember that this is a tab infected project, I'm adding the following lines:
:%s/\t/\s\s\s\s/g
set tabstop=2
set list listchars=tab:-\
Note that you can configure
with any of the following (or any other customized) methods.
lcs=tab:\-\
set list listchars=tab:>-,trail:-
set list listchars=tab:>-,eol:<,nbsp:%
set list listchars=extends:>,precedes:<
You can also show line endings to find those trailing spaces (grr) by using the listchars (lcs) options.
Last Updated: 2014-04-21 13:10:07