""" VIM config file | Jan Andrle | 2026-03-05 (VIM >=9.2 AppImage) "" #region B – Base scriptencoding utf-8 | set encoding=utf-8 set pythonthreedll=/lib/x86_64-linux-gnu/libpython3.12.so.1.0 let $BASH_ENV = "~/.bashrc" " preparation for moving to ~/.config/vim, but lots of plugins depend on the old path! let s:root = fnamemodify(resolve(expand(':p')), ':h') for dir in split(globpath(s:root . '/bundle', '*'), '\n') execute 'set runtimepath^=' . fnameescape(dir) endfor packadd! matchit packadd! cfilter let g:ft_man_folding_enable = 1 runtime! ftplugin/man.vim " set hidden execute 'source' fnameescape(s:root . '/rc-cat.vim') cabbrev %PWD% execute('pwd') cabbrev %CD% fnameescape(expand('%:p:h')) cabbrev %CS% mini_enhancement#selectedText() cabbrev %CW% echo '' let mapleader = "\\" " better for my keyboard, but maybe use `:help keymap`? nnoremap § @ nnoremap §§ @@ nnoremap ů ; nnoremap ; : nnoremap u U nnoremap U nnoremap ž nnoremap nnoremap " imap  cmap  " use tab/s-tab for tabnex/tabNext nnoremap :tabnext nnoremap :tabprevious set diffopt+=algorithm:patience,inline:word,linematch:60 augroup vimrc_help autocmd! autocmd BufEnter *.txt if &buftype == 'help' | wincmd L | vertical resize 90 | endif augroup END """ #region BB – Build-in plugins " https://github.com/rbtnn/vim-gloaded/blob/master/plugin/gloaded.vim let g:loaded_vimballPlugin = 1 " :h pi_vimball … for plugin creators let g:vifm_replace_netrw= 1 | let g:loaded_netrw= 1 | let g:loaded_netrwPlugin= 1 " this line needs to be commented to let vim dowmload spelllangs!!! … see http://jdem.cz/fgyw25 """ #endregion BB "" #endregion B "" #region H – Helpers command! -nargs=0 \ ALTredrawSyntax edit | exec 'normal `"' | exec 'set ft='.&ft let g:quickfix_len= 0 function! QuickFixStatus() abort hi! link User1 StatusLine if !g:quickfix_len | return 'Ø' | endif if g:quickfix_len>0 | return g:quickfix_len | endif let type= &termguicolors ? 'gui' : 'cterm' execute 'hi! User1 '.type.'bg='.synIDattr(synIDtrans(hlID('StatusLine')), 'bg'). \' '.type.'fg='.synIDattr(synIDtrans(hlID('WarningMsg')), 'fg') return -g:quickfix_len endfunction function! s:QuickFixCmdPost() abort let q_len= len(getqflist()) let g:quickfix_len= q_len ? -q_len : len(getloclist(0)) endfunction augroup quickfix autocmd! autocmd QuickFixCmdPost * call QuickFixCmdPost() augroup END "" #endregion H "" #region SLH – Status Line + Command Line + History (general) + Sessions + File Update, … " set showcmd showmode wildmenu … default since v9.2 set cmdheight=2 cmdwinheight=9 set wildoptions=pum,fuzzy wildmode=longest,full cabbrev wbw wbw set sessionoptions-=options function! NumberOfBuffers() return len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) endfunction set laststatus=2 " Show status line on startup set statusline+=··≡·%{QuickFixStatus()}%*··»·%{user_tips#current()}%*··%= set statusline+=(%{NumberOfBuffers()})··%<%f%R\%M··▶·%{&fileformat}·%{&fileencoding?&fileencoding:&encoding}·%{&filetype} set statusline+=·· " set statusline+=··∷·%{mini_sessions#name('–')}··  set history=500 " How many lines of (cmd) history has to remember set nobackup nowritebackup noswapfile " …there is issue #649 (for servers) and I’m using git/system backups try execute 'set undodir=' . fnameescape(s:root . '/undodir') . ' undofile' | catch | endtry command! HELPundoClear echo 'undolevel='.&undolevels "" #endregion SLH "" #region LLW – Left Column + Line + Wrap + Scrolling set signcolumn=yes set cursorline cursorcolumn " Always show current position set number foldcolumn=2 " enable line numbers and add a bit extra margin to the left set textwidth=120 colorcolumn=81,+1 command! HELPtextwidth echo "textwidth=".&textwidth." colorcolumn=".&colorcolumn set nowrap " Don't wrap long lines by default set breakindent breakindentopt=shift:2 showbreak=↳ set scrolloff=5 sidescrolloff=10 " offset for lines/columns when scrolling "" #endregion LLW "" #region CN – Clipboard + Navigation throught Buffers + Windows + … (CtrlP) set pastetoggle= | nnoremap :set invpaste paste? function! JaaCopyRegister() echo "Copy content of the register: " let sourceReg = nr2char(getchar()) if sourceReg !~# '\v^[a-z0-9"*+]' echon sourceReg." – invalid register" return endif echon sourceReg."\ninto the register: " let destinationReg = nr2char(getchar()) if destinationReg !~# '\v^[a-z0-9"*+]' echon destinationReg." – invalid register" return endif call setreg(destinationReg, getreg(sourceReg, 1)) echon destinationReg endfunction nnoremap " :call JaaCopyRegister() " CtrlP previously nmap š buffer_number("#")==-1 ? ":CocList --normal buffers\" : "\" nmap ě :CocList nmap 3 :buffers:b nmap š :CocList buffers | :syntax on nmap č š "" #endregion CN "" #region FOS – File(s) + Openning + Saving set autowrite autoread | autocmd FocusGained,BufEnter *.* checktime " set modeline … default since v9.2 command! HELPmodeline \ echo "tabstop=".&tabstop." shiftwidth=".&shiftwidth." textwidth=".&textwidth." expandtab=".&expandtab set path+=src/**,app/**,build/** " File matching for `:find` for ignore in [ '.git', '.npm', 'node_modules' ] exec ':set wildignore+=**'.ignore.'**' exec ':set wildignore+=**/'.ignore.'/**' endfor set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png,*.ico set wildignore+=*.pdf,*.psd function! Television(channel = '') let temp = tempname() echo temp execute '!tv '.a:channel.' > '.temp let lines = readfile(temp) if empty(lines) return endif let target = trim(lines[-1]) let target = escape(target, '$') let target = substitute(target, "[']", '', 'g') if target == '' return endif return target endfunction command! -nargs=* Television execute 'e '.Television() cabbrev tv Television function! Explore() let pwd = expand('%:p:h')->trim()->escape('$') let file = system('kdialog --getopenfilename --title "Vyberte soubor" "'.pwd.'" 2>/dev/null')->trim()->escape('$') if file != '' exec 'e '.file endif endfunction command! Explore call Explore() nmap e :Explore nnoremap gx :silent exec "!xdg-open '".shellescape(substitute(expand(''), '?', '\\?', ''), 1)."'" \| redraw! vnoremap gx :silent exec "!xdg-open '".shellescape(substitute(mini_enhancement#selectedText(), '?', '\\?', ''), 1)."'" \| redraw! "" #endregion FOS "" #region EN – Editor navigation + search set grepprg=LC_ALL=C\ grep\ -HRIns set hlsearch incsearch " highlight search, start when typing if maparg('', 'n') ==# '' nnoremap :nohlsearch=has('diff')?'diffupdate':'' | endif " TODO? syntax sync fromstart let g:markbar_persist_mark_names = v:false let g:markbar_cache_with_hidden_buffers = v:false " last buffers are reopened as hidden https://github.com/Yilin-Yang/vim-markbar/blob/9f5a948d44652074bf2b90d3da6a400d8a369ba5/doc/vim-markbar.txt#L136 nmap m ToggleMarkbar "" #endregion EN "" #region EA – Editing adjustment + Syntax + White chars + Folds " surround `:echo char2nr(…)` let g:surround_8222= "„\r”" let g:surround_8218= "‚\r’" let g:surround_8220= "“\r”" let g:surround_8216= "‘\r’" function! s:SmartQuoteTextObject(inner) abort let open = '[“‘„‚]' let close = '[”’]' let start = searchpos(open, 'bncW') let end = searchpos(close, 'ncW') if start[0] == 0 || end[0] == 0 return endif if a:inner let open_len = matchstr(getline(start[0]), '.', start[1] - 1)->len() call cursor(start[0], start[1] + open_len) normal! v call cursor(end[0], end[1] - 1) else call cursor(start) normal! v let close_len = matchstr(getline(end[0]), '.', end[1] - 1)->len() call cursor(end[0], end[1] + close_len - 1) endif endfunction xnoremap iq :call SmartQuoteTextObject(1) onoremap iq :call SmartQuoteTextObject(1) xnoremap aq :call SmartQuoteTextObject(0) onoremap aq :call SmartQuoteTextObject(0) " use § for § inoremap § set nrformats-=octal let g:htl_css_templates=1 let g:markdown_fenced_languages= [ 'javascript', 'js=javascript', 'json', 'html', 'php', 'bash', 'vim', 'vimscript=javascript', 'sass', 'diff' ] augroup convenient autocmd! autocmd FileType markdown,json setlocal conceallevel=2 autocmd FileType markdown,text setlocal keywordprg=dict autocmd FileType git,gitcommit setlocal foldmethod=syntax foldlevel=1 augroup END " PARENTHESES plugin junegunn/rainbow_parentheses.vim let g:rainbow#pairs= [['(', ')'], ['[', ']'], [ '{', '}' ]] let g:rainbow#blacklist = [203,9] autocmd VimEnter * try \| call rainbow_parentheses#toggle() | catch | endtry " HIGHLIGHT&YANK plugins (buildin) hlyank & cwordhi.vim packadd hlyank let g:hlyank_duration= 250 let g:cwordhi#autoload= 1 set showmatch " Quick highlight oppening bracket/… for currently writted " set timeoutlen=1000 … default since v9.2 set ttimeoutlen=0 " Remove timeout when hitting escape TAB set formatoptions+=j " Delete comment character when joining commented lines set smarttab command! -nargs=1 SETtab let &shiftwidth= | let &tabstop= | let &softtabstop= SETtab 4 " set backspace=indent,eol,start " default since v9.2: Allow cursor keys in insert mode: http://vi.stackexchange.com/a/2163 set shiftround autoindent " round diff shifts to the base of n*shiftwidth, https://stackoverflow.com/a/18415867 filetype plugin indent on " SYNTAX&COLORS if ($TERM =~ '256' && has("termguicolors")) set termguicolors | endif if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") syntax enable | endif set list listchars=tab:»·,trail:·,extends:#,nbsp:~,space:· " Highlight spec. chars / Display extra whitespace set redrawtime=10000 let g:vim_vue_plugin_config = { 'foldexpr': 1, 'attribute': 1, 'keyword': 1 } " SPELL if !has("gui_running") hi clear SpellBad | hi SpellBad cterm=underline,italic | endif command HELPspell echo 'spelllang='.&spelllang.' spell='.&spell.' spellfile='.&spellfile " EDIT HEPERS nnoremap o o nnoremap O O nnoremap a for l in [ 'y', 'p', 'P', 'd' ] | for m in [ 'n', 'v' ] execute m.'map '.l.' "+'.l | endfor | endfor " no noremap ⇐ https://github.com/jasonccox/vim-wayland-clipboard?tab=readme-ov-file#non-recursive-mappings command HELPfold echo 'foldmethod='.&foldmethod.' foldlevel='.&foldlevel.' foldnestmax='.&foldnestmax set foldmarker=#region,#endregion " SAVE VIEW set viewoptions=cursor,folds augroup remember__view autocmd! autocmd BufWinLeave *.* if &buflisted | mkview | endif autocmd BufWinEnter *.* silent! loadview augroup END "" #endregion EA "" #region AI let g:codeium_disable_bindings = 1 imap