add vimrc

This commit is contained in:
Thomas von Dein 2024-11-25 11:15:18 +01:00
parent 2ca75ee186
commit b58865cf88

View File

@ -0,0 +1,116 @@
" concentrate backup files etc
let &directory = expand('~/.vimdata/swap//')
set backup
let &backupdir = expand('~/.vimdata/backup//')
set undofile
let &undodir = expand('~/.vimdata/undo//')
if !isdirectory(&undodir) | call mkdir(&undodir, "p") | endif
if !isdirectory(&backupdir) | call mkdir(&backupdir, "p") | endif
if !isdirectory(&directory) | call mkdir(&directory, "p") | endif
" allow backspacing over everything in insert mode
set bs=2
" no auto indent
set nosmartindent
set noautoindent
" smart indent with code
autocmd FileType perl set smartindent
autocmd FileType python set smartindent
autocmd FileType shell set smartindent
autocmd FileType c set smartindent
" paste mode - this will avoid unexpected effects when you
" cut or copy some text from one window and paste it in Vim.
set pastetoggle=<F11>
" indent shifts 2 spaces to right
set expandtab
set shiftwidth=2
set softtabstop=2
set smarttab
" show matches when using completion
set wildmenu
" search is case insensitive
set ignorecase
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" highlight matches
set hlsearch
" not case insensitive if term contains upper letters
set smartcase
" show cursor position in statusline
set ruler
" show matching bracket after typing a closing bracket
set showmatch
" show current mode in statusline
set showmode
" show last command in statusline
set showcmd
" show status line
set laststatus=2
" set xterm title to "VIM <file>", while <file> is
" the currently opened buffer
set title
" do not beep (doh!)
set visualbell
" don't ask for :x!
set writeany
" just enter Q to exit
map Q :q!<Cr>
" fix broken shells
set term=xterm
" enable true colors
set termguicolors
" add comment char when pressing <Cr> inside comment line
set formatoptions+=r
" show line numbers
" set number
set relativenumber
set numberwidth=5
" to disable linenumbers and indentlines (if any) press t in normal mode
nmap t :set relativenumber!<CR>:IndentLinesToggle<CR>
" help in full screen
command! -nargs=1 -complete=help H help <args> | silent only
if &diff
" apply right patch to the left
nnoremap < :diffget <Enter>
" apply left patch to the right
nnoremap > :diffput <Enter>
" update diff
nnoremap <C-l> :diffupdate <Enter>
" jump to next diff
map n ]c
" jump to previous diff
map p [c
" switch windows (back and forth)
nnoremap <C-o> <C-W>w
endif