Hlavní navigace

Názor ke článku Jak si správně nastavit .vimrc od abyssal - Vybral som par (snad) uzitocnych hlavne vizualnych veci...

  • 6. 11. 2007 17:00

    abyssal (neregistrovaný)

    Vybral som par (snad) uzitocnych hlavne vizualnych veci z .vimrc (som zvedavy jak to naformatuje):

    "1) zvyraznenie status line - odlisenie command mode a insert mode, naviac nastavi zvyraznenie aktivneho riadku v insert mode. Ta funkcia CulInInsertMode je potrebna aby to fungovalo aj pri prepnuti tabov spravne. Prikazy highlight su nastavenia farbiciek v gui mode a text mode, pripadne si zmente

    " highlighting command/insert modes
    highlight StatusLine guifg=red guibg=white ctermfg=red ctermbg=white
    autocmd! InsertEnter * highlight StatusLine guifg=blue guibg=white ctermfg=green ctermbg=white
    autocmd InsertEnter * set cul
    autocmd! InsertLeave * highlight StatusLine guifg=red guibg=white ctermfg=red ctermbg=white
    autocmd InsertLeave * set nocul
    autocmd! WinLeave * set nocul
    autocmd! WinEnter * call CulInInsertMode()

    " set cursorline in insert mode, not in command mode
    function! CulInInsertMode()
    if mode()=="i"
    set cul
    else
    set nocul
    endif
    endfunction

    "2) spustanie make prikazu cez F7 a navigovanie cez najdene chyby cez F5/F6; :make nemusi volat nutne 'make', ale aj iny tool/prekladac, viz :help makeprg
    " make and navigating through errors
    nnoremap <F5> :cN<CR>
    nnoremap <F6> :cn<CR>
    nnoremap <F7> :make<CR>

    "3) oznacovanie Shift+Up/Down/..., Shift+Insert, Shift+Del; tieto typicky nebudu fungovat v terminali, lebo ten ich odchyti na scrolovanie apod.
    " Shift-Up/Down switches to line-visual
    inoremap <S-Down> <Esc>V
    inoremap <S-Up> <Esc>V
    vnoremap <S-Down> <Down>
    vnoremap <S-Up> <Up>
    nnoremap <S-Down> V
    nnoremap <S-Up> V
    " Shift-Left/Right switches to character-visual
    inoremap <S-Left> <Esc>v
    inoremap <S-Right> <Esc>v
    vnoremap <S-Left> <Left>
    vnoremap <S-Right> <Right>
    nnoremap <S-Left> v
    nnoremap <S-Right> v
    " Shift-Home/End switches to character-visual, choosing till EOL
    inoremap <S-Home> <Esc>v<Home>
    inoremap <S-End> <Esc>v<End><Left>
    vnoremap <S-Home> <Home>
    vnoremap <S-End> <End><Left>
    nnoremap <S-Home> v<Home>
    nnoremap <S-End> v<End><Left>
    " Ctrl-Insert is copy (yank)
    vnoremap <C-Insert> "+y
    " Shift-Insert is paste, Shift-Del is cut
    vnoremap <S-Insert> <Esc>"+gP
    inoremap <S-Insert> <C-R>+
    nnoremap <S-Insert> "+gP
    vnoremap <S-Del> "+x

    "4) Podrobnejsia status line, ukazuje cislo buffera, filetype, encoding, lineendings, poziciu absolute a percenta, modified flag atd.
    " Status line setting
    set laststatus=2
    set statusline=%{&mo­dified?'[+]':'\ \ \ \ '}\
    set statusline+=%-3.3n\ " buffer number
    set statusline+=%f\ " file name
    set statusline+=\[%{strl­en(&ft)?&ft:'no­ne'},
    set statusline+=%{&en­coding},
    set statusline+=%{&fi­leformat}]
    set statusline+=%= " right align
    set statusline+=%-14.(%l,%c%V%)\ %<%P/%L " offset