Although not perl code, this has sped up my development in perl markedly.
Stole (and altered) this off a friend of mine who found it and altered it somewhere else.
For those who are that way inclined, you can also do similar things with php.
Simple instruction: F1 validates the per... checking for syntax errors etc etc, and brings up the results in a new window. f2 closes the window.
f3 runs the perl script, bringing up the results in a new window. (again) f2 closes the window. Generally, I use this for debugging.
Improvements and suggestions welcomed.
" F2 close current window (commonly used with my F1/F3 functions)
noremap <f2> <Esc>:close<CR><Esc>
" perl -cw buffer, using a temp file, into a new window
function! PerlCW()
let l:tmpfile1 = tempname()
let l:tmpfile2 = tempname()
execute "normal:w!" . l:tmpfile1 . "\<CR>"
execute "normal:! perl -cw ".l:tmpfile1." \> ".l:tmpfile2." 2\>\&1
+ \<CR>"
execute "normal:new\<CR>"
execute "normal:edit " . l:tmpfile2 . "\<CR>"
endfunction
" perl buffer, using a temp file, into a new window
function! PerlOutput()
let l:tmpfile1 = tempname()
let l:tmpfile2 = tempname()
execute "normal:w!" . l:tmpfile1 . "\<CR>"
execute "normal:! perl ".l:tmpfile1." \> ".l:tmpfile2." 2\>\&1 \<C
+R>"
execute "normal:new\<CR>"
execute "normal:edit " . l:tmpfile2 . "\<CR>"
endfunction
" Settings for editing perl source (plus bind the above two functions)
function! MyPerlSettings()
if !did_filetype()
set filetype=perl
endif
set textwidth=78
set expandtab
set tabstop=4
set shiftwidth=4
set cindent
set comments=:#
set formatoptions=croql
set keywordprg=man\ -S\ 3
noremap <f1> <Esc>:call PerlCW()<CR><Esc>
noremap <f3> <Esc>:call PerlOutput()<CR><Esc>
endfunction
if has("eval")
augroup SetEditOpts
au!
autocmd FileType perl :call MyPerlSettings()
augroup END
endif
endif
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|