Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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, Inc.

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

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

  • 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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-10-27 07:27 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (91 votes). Check out past polls.