Sources de la conf...

Configuration de vim

Mais c'est pourquoi faire ?

Pour faire do collapse de code perl avec vi.

Les touches:

  • `za` - toggles
  • `zc` - closes
  • `zo` - opens
  • `zR` - open all
  • `zM` - close all

contenu du ~/.vimrc

set bg=dark
set tabstop=4
set expandtab
syntax on
set encoding=utf-8
set fileencoding=utf-8
set foldmethod=indent   "fold based on indent
set foldnestmax=10      "deepest fold is 10 levels
set nofoldenable        "dont fold by default
set foldlevel=1         "this is just what i use
function GetPerlFold()
  if getline(v:lnum) =~ '^\s*sub\s'
    return ">1"
  elseif getline(v:lnum) =~ '\}\s*$'
    let my_perlnum = v:lnum
    let my_perlmax = line("$")
    while (1)
      let my_perlnum = my_perlnum + 1
      if my_perlnum > my_perlmax
        return "<1"
      endif
      let my_perldata = getline(my_perlnum)
      if my_perldata =~ '^\s*\(\#.*\)\?$'
        " do nothing
      elseif my_perldata =~ '^\s*sub\s'
        return "<1"
      else
        return "="
      endif
    endwhile
  else
    return "="
  endif
endfunction
setlocal foldexpr=GetPerlFold()
setlocal foldmethod=expr

docs/linuxeries/vi.txt · Dernière modification: 2013/11/02 23:04 (édition externe)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki