MyVimrc

Here is my actual .vimrc code:

colorscheme evening

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible    " Use Vim defaults (much better!)
set backspace=2     " allow backspacing over everything in insert mode
" Now we set some defaults for the editor 
"set autoindent     " always set autoindenting on
"set nobackup        " Don't keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more than
            " 50 lines of registers
            set history=50      " keep 50 lines of command line history
            set ruler       " show the cursor position all the time
            " Suffixes that get lower priority when doing tab completion for filenames.
            " These are files we are not likely to want to edit or read.
            set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

set ruler
syntax on
set ai


set incsearch    " incremental search
set showmatch
set showcmd

" interpret tab as an `indent' command instead of an insert-a-tab command
set softtabstop=4
"indent with two spaces when hitting tab 
set shiftwidth=4
"expand all tabs to spaces according to shiftwidth parameter
set expandtab


nnoremap \hc :call InsertCloseTag()<CR>
imap <F8> <Space><BS><Esc>\hca

" With the above mapping and the following function, while typing in insert mode, you can simply press <F8> to have any close tag typed tag for you. (If function keys don.t work in your terminal, then use \hc in normal mode instead.)

function! InsertCloseTag()
" inserts the appropriate closing HTML tag; used for the \hc operation defined
" above;
" requires ignorecase to be set, or to type HTML tags in exactly the same case
" that I do;
" doesn't treat <P> as something that needs closing;
" clobbers register z and mark z
"
" by Smylers  http://www.stripey.com/vim/
" 2000 May 3

  if &filetype == 'html'

    " list of tags which shouldn't be closed:
    let UnaryTags = ' Area Base Br DD DT HR Img Input LI Link Meta P Param '

    " remember current position:
    normal mz

    " loop backwards looking for tags:
    let Found = 0
    while Found == 0
      " find the previous <, then go forwards one character and grab the first
      " character plus the entire word:
      execute "normal ?\<LT>\<CR>l"
      normal "zyl
      let Tag = expand('<cword>')

      " if this is a closing tag, skip back to its matching opening tag:
      if @z == '/'
        execute "normal ?\<LT>" . Tag . "\<CR>"

      " if this is a unary tag, then position the cursor for the next
      " iteration:
      elseif match(UnaryTags, ' ' . Tag . ' ') > 0
        normal h

      " otherwise this is the tag that needs closing:
      else
        let Found = 1

      endif
    endwhile " not yet found match

    " create the closing tag and insert it:
    let @z = '</' . Tag . '>'
    normal `z"zp

  else " filetype is not HTML
    echohl ErrorMsg
    echo 'The InsertCloseTag() function is only intended to be used in HTML ' .
      \ 'files.'
    sleep
    echohl None

  endif " check on filetype

endfunction " InsertCloseTag()

LucasArruda/MyVimrc (last edited 2008-08-06 16:31:20 by localhost)