Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
These are all great. Because of all of your autocmd lines, I'd suggest creating a function to be called:

function! Perl() " autoindent set autoindent set smartindent " 4 space tabs set tabstop=4 set shiftwidth=4 set expandtab set softtabstop=4 " show matching brackets set showmatch " show line numbers set number " check perl code with :make set makeprg=perl\ -c\ %\ $* set errorformat=%f:%l:%m set autowrite endfunction " Call Perl() when you open a Perl file autocmd FileType perl call Perl()

Now, I have some things to add that I really like. I like cindent because I can control the indentation style with some rules. I can also add to or remove from the list of indentation keywords:

" restore defaults (incase I :e or :sp) set cinkeys& " don't go to column zero when # is the first thing on the line set cinkeys-=0# " restore defaults set cinwords& " add Perl-ish keywords set cinwords+=elsif,foreach,sub,unless,until set cinoptions& " I don't rememer these OTTOMH; :help cinoptions to learn more set cinoptions+=+2s,(1s,u0,m1 set cindent

Then sometimes I want <Tab> to indent (insert a tab), sometimes I want it to do word autocompletion (like bash). So, I stole^H^H^H^H^Hborrowed this from a former coworker:

" SmartTab wrapper function! SmartTab() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\<tab>" else return "\<c-p>" endif endfunction " turn on SmartTabs inoremap <tab> <c-r>=SmartTab()<cr>

Then a current coworker found/modified/developed (not totally sure which) this nifty status bar which tells you what function (sub) you are in:

set statusline=%f%{CurrSubName()}\ %m%h%r\ %=%25(%-17(%l\,%c%V%)\ %p +%%%) set laststatus=2 set maxfuncdepth=250 function! CurrSubName() let g:subname = "" let g:subrecurssion = 0 " See if this is a Perl file let l:firstline = getline(1) if ( l:firstline =~ '#!.*perl' || l:firstline =~ '^package ' ) call GetSubName(line(".")) endif return g:subname endfunction function! GetSubName(line) let l:str = getline(a:line) if l:str =~ '^sub' let l:str = substitute( l:str, " *{.*", "", "" ) let l:str = substitute( l:str, "sub *", ": ", "" ) let g:subname = l:str return 1 elseif ( l:str =~ '^}' || l:str =~ '^} *#' ) && g:subrecurssion == + 1 return -1 elseif a:line > 2 let g:subrecurssion = g:subrecurssion + 1 if g:subrecurssion < 190 call GetSubName(a:line - 1) else let g:subname = ': <too deep>' return -1 endif else return -1 endif endfunction
Finally, everyone has their way to do compiler checks, block comment/uncomment, etc. Mine are:
map !! :!perl -c %<CR> map ## :s/^/#/<CR> map !# :s/^#//<CR>

These are, of course, all part of my Perl() function. I have others for toggling list, paste, number, and wrap. And since I use split windows I map Ctrl+[arrow keys] to move between panes. This one is tricky because it really depends on terminal settings; I'm still working on some bugs with it.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.

In reply to Re: .vimrc for perl programmers by Codon
in thread .vimrc for perl programmers by nferraz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (8)
    As of 2015-07-04 16:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (60 votes), past polls