vim cheatsheet

vim

:%s/search/replace/g

:set autoindent noai               => autoindent abschalten
:g/alter text/s//neuer text/g      => suchen/ersetzen
:set nu                            => linenumbers einschalten
:set bg=dark                       => dunkle farben (z.B blau) heller machen
:set list                          => steuerzeichen einschalten

für ganzen server:
/etc/vim/vimrc:
set autoindent noai
syntax on


##### add syntax highlighting for any filetype (thtml / cake)
/usr/share/vim/vim63/filetype.vim
-> add *.thtml @ PHP section


vimrc erstellen:
:mkvimrc

___VIMRC______________________
" Klemens' .vimrc 2006-04-14
"

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the time
set showcmd     " display incomplete commands
" set incsearch     " do incremental searching

" Don't use Ex mode, use Q for formatting
map Q gq


" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
"  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")
  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

endif " has("autocmd")


" for PHP / pear
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4

" other stuff
set bg=light    "because I'm working with white terminal background color
set paste       "no autoindent when pasting