dotfiles/vim/vimrc
2017-01-26 13:48:55 +01:00

108 lines
2.7 KiB
VimL

"" Syntaxhervorhebung
syntax on
set encoding=utf-8
"" weite Möglichkeiten zur Einstellung des Zeichensatzes
" set termencoding=iso-8859-15
" set fileencodings=ucs-bom,utf-8,latin1
"" immer die Statuszeile mit dem Dateinamen anzeigen
set ls=2
"" automatischer Zeilenumbruch, wenn die Zeile zu lang ist
set wrap
" set nowrap
"" Kompatibilitätsmodus zu vi abschalten
set nocompatible
"" Wieviele Leerzeichen lang ist ein Tabulator?
set ts=2
"" Ersetze Tabulatoren durch Leerzeichen
" set expandtab
"" Einrückungstiefe
set shiftwidth=2
"" Einrückungen im C-Stil
" set cindent
"" alternative Einrückungsstile
" set autoindent
" set smartindent
"" zeigt unten links diverse Positionsinformationen der Schreibmarke
set ruler
"" die Shell, die beim Starten von Programmen aus dem Editor heraus verwendet werden soll
set shell=/bin/bash
"" zeigt in der Statuszeile an, ob man sich im Einfügemodus (INSERT) oder im Ersetzungsmodus (REPLACE) befindet
set showmode
"" Zeilennummern anzeigen
set number
"" Verhalten der Rückschritttaste
set backspace=indent,eol,start
"" F9 wechselt Syntaxhervorhebung
map <F9> :if has("syntax_items")<CR>syntax off<CR>else<CR>syntax on<CR>endif<CR><CR>
"" F8 wechselt Zeilenubruch
map <F8> :if has("nowrap_items")<CR>set nowrap<CR>else<CR>set wrap<CR>endif<CR><CR>
"" nicht an den Zeilenanfang bei Benutzung von Bild auf und Bild ab gehen
set nostartofline
"" Suchergebnisse hervorheben
set hlsearch
set incsearch
set ignorecase
set smartcase
"" Wer die Maus für übliches Copy&Paste verwenden will, der sollte diese Zeile hinzufügen:
set mouse=
nnoremap <C-H> :Hexmode<CR>
inoremap <C-H> <Esc>:Hexmode<CR>
vnoremap <C-H> :<C-U>Hexmode<CR>
" ex command for toggling hex mode - define mapping if desired
command -bar Hexmode call ToggleHex()
" helper function to toggle hex mode
function ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd
else
" restore old options
let &ft=b:oldft
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction