Advertisement
arkanon

/usr/share/vim/vimrc

May 9th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 9.73 KB | None | 0 0
  1. " /usr/share/vim/vimrc
  2.  
  3. " Arkanon <arkanon@lsd.org.br>
  4. " 2011/04/18 (Seg) 14:31:30 (BRS)
  5. " 2009/09/29 (Ter) 21:51:57 (BRS)
  6.  
  7. " TODO
  8. "
  9. "   - auto-close of ), ] and } when in front of non-null strings
  10. "   - auto-close of ' and "
  11. "  ok multiply match use (/ceat/ and /[ \t]*/)
  12. "   - auto-source .vimrc on save
  13. "   - auto-reload script on save
  14.  
  15. " In vim help (:h [keyword])
  16. "  - follow a link: position the cursor between |bars| and hit CTRL-]
  17. "  -       go back: type CTRL-T or CTRL-O (repeat to go further back)
  18.  
  19.  
  20.  
  21. " Use Vim settings, rather then Vi settings (much better!).
  22. " This must be first, because it changes other options as a side effect.
  23.  set nocompatible
  24.  
  25.  
  26.  
  27.  if has('win32')
  28.     lang Portuguese_Brazil
  29. "   let $VIMRUNTIME = 'h:\_opt\office\vim\default\share'
  30. "   let $FS         = 'h:\_opt\office\vim\ceat'
  31.  endif
  32.  
  33.  if has('unix')
  34.     lang pt_BR.UTF8
  35. "   let $FS         = '/export/fs/etc/vim'
  36.  endif
  37.  
  38.  set spelllang=pt
  39. "set spell
  40.  
  41. "set rtp=~/.vim,$FS,$VIMRUNTIME
  42.  
  43. "helptags ~/.vim/doc
  44. "helptags $VIMRUNTIME/doc/Align.txt
  45. "runtime  plugins/Align.vim
  46. "runtime  plugins/AlignMaps.vim
  47. "runtime  plugins/TagList.vim
  48.  
  49.  
  50. " Tell vim to remember certain things when we exit
  51. "  '50  : marks will be remembered for up to # previously edited files
  52. "  "100 : will save up to # lines for each register
  53. "  :50  : up to # lines of command-line history will be remembered
  54. "  %    : saves and restores the buffer list
  55. "  n... : where to save the viminfo files
  56.  set viminfo='50,\"100,:50,%,n~/.viminfo
  57.  
  58. " jumps to the last known position in a file just after opening it, if the '"' mark is set.
  59. " don't do it if position is invalid or inside an event handler (happens when dropping a file on gvim).
  60.  au BufReadPost *
  61.  \ if line("'\"") > 0 && line("'\"") <= line("$")
  62.  \ | exe "normal! g`\""
  63.  \ | endif
  64.  
  65.  
  66.  
  67. " taglist
  68.  let Tlist_Auto_Open               = 0
  69.  let Tlist_Exit_OnlyWindow         = 1
  70.  let Tlist_GainFocus_On_ToggleOpen = 0
  71.  let Tlist_Inc_Winwidth            = 0
  72.  let Tlist_Show_One_File           = 1
  73.  let Tlist_Use_SingleClick         = 0
  74.  let Tlist_Compact_Format          = 1
  75.  let Tlist_Display_Tag_Scope       = 1
  76.  let Tlist_Close_On_Select         = 0
  77.  let Tlist_WinWidth                = 22
  78.  nnoremap <silent> T :TlistToggle<cr>
  79.  
  80.  
  81.  
  82. " function/class folding for php files
  83.  map <c-f5> <esc>:EnableFastPHPFolds<cr>
  84.  map <c-f6> <esc>:EnablePHPFolds<cr>
  85.  map <c-f7> <esc>:DisablePHPFolds<cr>
  86. "let g:DisableAutoPHPFolding = 1
  87.  
  88.  
  89.  
  90. " tabs navigation
  91.  set tabpagemax=30
  92.  map th :tabfirst<cr>
  93.  map tj :tabnext<cr>
  94.  map tk :tabprev<cr>
  95.  map tl :tablast<cr>
  96.  map td :tabclose<cr>
  97.  map tt :tabedit<space>
  98.  map tn :tabnew<space>
  99.  map tm :tabm<space>
  100.  
  101.  
  102.  
  103. " text alignment
  104. "
  105.  runtime macros/justify.vim " maps _j to justify macro, in both normal and visual modes
  106. "
  107. " idem, to _c and center command
  108.  nmap _c :center<cr>
  109.  vmap _c :center<cr>
  110. "
  111. " idem, to _l and left   command
  112.  nmap _l :left<cr>
  113.  vmap _l :left<cr>
  114. "
  115. " idem, to _r and right  command
  116.  nmap _r :right<cr>
  117.  vmap _r :right<cr>
  118.  
  119.  
  120.  
  121. " Enable file type detection.
  122. " Use the default filetype settings, so that mail gets 'tw' set to 72,
  123. " 'cindent' is on in C files, etc.
  124. " Also load indent files, to automatically do language-dependent indenting.
  125. "filetype plugin indent on
  126.  
  127. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  128. "let &guioptions = substitute(&guioptions, "t", "", "g")
  129.  
  130.  
  131.  
  132. "set ts=10          " tab stop  = define o tamanho do tab
  133. "set et             " expandtab = tab é convertido em espaços
  134. "ret                " 'retabula', substituindo tabs por espaços
  135. "
  136.  
  137.  
  138.  
  139. " File format
  140. "set ff=dos         " <cr><nl>
  141. "set ff=unix            " <nl>
  142. "set ff=mac         " <cr>
  143.  
  144.  
  145.  
  146. " alinha pelo caracter '=', deve haver uma linha em branco antes
  147.  map <c-a> !}<bs>Align =<cr>
  148.  
  149.                 " teste: afhjki= 44
  150.                 "        d= 546
  151.  
  152.  
  153.  
  154. " Don't use Ex mode, use Q for formatting
  155.  map Q gq
  156. "set tw=125         " text width
  157. "gq}                " reformata a largura da linha conforme tw
  158.  
  159.  
  160.  
  161.  syntax on
  162.  set nohlsearch         " no highlights search results
  163.  
  164. " <http://vim.wikia.com/wiki/Highlight_unwanted_spaces>
  165.  autocmd Syntax * syntax match TailSpace /\s\+$\| \+\ze\t/                 containedin=ALL
  166.  autocmd Syntax * syntax match todo      /\<\CTODO\>/                      containedin=ALL
  167.  autocmd Syntax * syntax match bug       /\<\CBUG\>\|\<\CBUGS\>/           containedin=ALL
  168.  autocmd Syntax * syntax match erro      /\<\CERRO\>/                      containedin=ALL
  169.  autocmd Syntax * syntax match feature   /\<\CFEATURE\>\|\<\CFEATURES\>/   containedin=ALL
  170.  autocmd Syntax * syntax match ok        /\<\cok\>/                        containedin=ALL
  171.  autocmd Syntax * syntax match no        /\<\cno\>/                        containedin=ALL
  172.  autocmd Syntax * syntax match problema  /\<\CPROBLEMA\>\|\<\CPROBLEMAS\>/ containedin=ALL
  173.  autocmd Syntax * syntax match resolvido /\<\CRESOLVIDO\>/                 containedin=ALL
  174.  autocmd Syntax * syntax match resolver  /\<\CRESOLVER\>/                  containedin=ALL
  175.  
  176.  highligh TailSpace ctermbg=lightred   guibg=lightred
  177.  highligh todo      ctermbg=yellow     guibg=yellow    cterm=bold gui=bold ctermfg=black guifg=black
  178.  highligh bug       ctermfg=red        guifg=red       cterm=bold gui=bold
  179.  highligh erro      ctermfg=red        guifg=red       cterm=bold gui=bold
  180.  highligh feature   ctermfg=blue       guifg=blue      cterm=bold gui=bold
  181.  highligh ok        ctermfg=darkgreen  guifg=darkgreen cterm=bold gui=bold
  182.  highligh no        ctermfg=red        guifg=red       cterm=bold gui=bold
  183.  highligh problema  ctermbg=red        guibg=red       cterm=bold gui=bold ctermfg=white guifg=white
  184.  highligh resolvido ctermbg=lightgreen guibg=lightgreen
  185.  highligh resolver  ctermbg=yellow     guibg=yellow
  186.  
  187.  
  188.  
  189.  function! TextEnableCodeSnip(filetype,start,end,textSnipHl) abort
  190.  " <http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file>
  191.    let ft=toupper(a:filetype)
  192.    let group='textGroup'.ft
  193.    if exists('b:current_syntax')
  194.      let s:current_syntax=b:current_syntax
  195.      " Remove current syntax definition, as some syntax files (e.g. cpp.vim)
  196.      " do nothing if b:current_syntax is defined.
  197.      unlet b:current_syntax
  198.    endif
  199.    execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
  200.    try
  201.      execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
  202.    catch
  203.    endtry
  204.    if exists('s:current_syntax')
  205.      let b:current_syntax=s:current_syntax
  206.    else
  207.      unlet b:current_syntax
  208.    endif
  209.    execute 'syntax region textSnip'.ft.'
  210.   \ matchgroup='.a:textSnipHl.'
  211.   \ start="'.a:start.'" end="'.a:end.'"
  212.   \ contains=@'.group
  213.  endfunction
  214.  
  215.  call TextEnableCodeSnip( 'php'  , '<?php'    , '?>'  , 'SpecialComment' )
  216.  call TextEnableCodeSnip( 'html' , 'print \"' , '\";' , 'SpecialComment' )
  217.  
  218.  
  219.  
  220. "set mouse=r
  221.  set nomousehide        " don't hide the mouse pointer while typing
  222.  
  223.  set backspace=indent,eol,start " allow backspacing over everything in insert mode
  224.  set history=50         " keep 50 lines of command line history
  225.  set showcmd            " display incomplete commands
  226.  set incsearch          " do incremental searching
  227.  
  228.  
  229.  set noai           " no autoindent
  230.  set indentexpr=
  231.  
  232.  
  233.  set novb t_vb=         " use audio bell
  234.  set nobackup
  235.  set nowrap
  236.  
  237.  set ruler          " show the cursor position all the time
  238.  
  239. " <http://www.faqs.org/faqs/editor-faq/vi/part2/>
  240. " ctrl-c cannot be remapped when it is defined as the interrupt character in Unix
  241.  vmap <a-c> :y+<cr>
  242.  set paste
  243.  
  244. "map <c-t> :w!<cr>:!aspell check %<cr>:e! %<cr>
  245.  map <f1>  :execute "help ".expand("<cword>")<cr>
  246.  map <f2>  dwi  <esc>jb/ <cr>
  247.  map <f3>  0i   <esc>Jr j
  248.  map <f4>  mz<esc>c$<c-r>=strftime("%Y/%m/%d %T")<cr><esc>`z
  249.  map <f5>  mz<esc>c$<c-r>=strftime("%Y/%m/%d (%a) %T (%Z)")<cr><esc>`z
  250. imap <f5>  <c-r>=strftime("%Y/%m/%d (%a) %T (%Z)")<cr>
  251.  map <f6>  mz<esc>c$<c-r>=strftime("%d/%m/%Y %a %T")<cr><esc>`z
  252.  map <f7>  mz<esc>c$<c-r>=strftime("%c")<cr><esc>`z
  253.  map <f8>  mz<esc>:%s/\s\+$//g<cr>`z
  254.  map <f11> :tab ball<cr>
  255.  
  256. " insert current file name without extension
  257.  map ff :execute "normal i".expand("%:r")<cr>l
  258.  
  259. " insert current file name with full path
  260.  map FF :execute "normal i".expand("%:p")<cr>l
  261.  
  262.  map ,v :w<cr>:e ~\.vimrc<cr>   " edits   .vimrc
  263.  map ,u :source  ~/.vimrc<cr>   " reloads .vimrc
  264.  
  265. " auto-close {, ( and [
  266. "imap { {}<left>
  267. "imap ( ()<left>
  268. "imap [ []<left>
  269.  
  270. " removes auto command for wrap text files
  271.  au! BufRead *.txt
  272.  
  273. " if editing a new registry file, auto includes standard header with filename as first comment
  274.  au BufNewFile *.reg  set ff=dos | execute "normal iREGEDIT4\<cr>\<cr>; ".expand("<afile>:r")."\<cr>\<cr>"
  275. " if editing a registry file, sets ff do dos (cr+lf)
  276.  au FileType registry set ff=dos
  277.  
  278. " if editing .vimrc, sources it-self after saving
  279. "echo "."
  280. "au BufWritePost ~/.vimrc source ~/.vimrc
  281.  
  282.  au FileType crontab  set compatible
  283.  au FileType xhtml    set enc=utf-8
  284.  
  285.  au BufNewFile,BufRead *.js.php,*.javascript.php,*.es.php   setf javascript
  286.  au BufNewFile,BufRead *.svg.php                setf xml
  287.  au BufNewFile,BufRead *.css.php                setf css
  288.  au BufNewFile,BufRead *.php,*.phps,*.php\d,*.phtml,*.ctp   setf php
  289.  
  290. " Open multiple files in tabs.
  291. "au BufReadPost * tab ball
  292.  
  293. " automatically give executable permission to scripts starting with #!/usr/bin/perl and #!/bin/sh
  294. "au BufWritePost * if getline(1) =~ "^#!/bin/[a-z]*sh" || getline(1) =~ "^#!/usr/bin/perl" | silent execute "!chmod +x <afile>" | endif
  295. "au BufWritePost * if getline(1) =~ "^#!/bin/[a-z]*sh" || getline(1) =~ "^#!/usr/bin/perl"
  296. "au BufWritePost *    silent execute "!chmod +x <afile>"
  297. "au BufWritePost *    edit
  298. "au BufWritePost * endif
  299.  
  300. "set statusline=[%{&ff}]\ %y\ [asc\ \%03.3b,#\%02.2B]\ [%l/%L(%p%%),%v]\ %m\ %r\ %h\ %w
  301. "set laststatus=2       " ever shows status line
  302.  
  303. "if $LIGHT_TERM
  304. "   colorscheme light
  305. "else
  306. "   colorscheme dark
  307. "endif
  308.  
  309. " EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement