VIM TIPS2

    xiaoxiao2026-05-03  9

    autocmd BufWritePost * if &diff == 1 | diffupdate | endif let mapleader = ',' "delete current line in insert mode inoremap <c-d> <esc>ddi                   "lower current word in insert mode inoremap <c-u> <esc>viwuea "upper current word in insert mode inoremap <a-u> <esc>viwUea "Capital current word in insert mode inoremap <a-c> <esc>BvUlveuea "Edit vimrc file in normal mode nnoremap <leader>ev :vsplit $MYVIMRC<cr> "Source vimrc file in mormal mode nnoremap <leader>sv :source $MYVIMRC<cr> "Enclose current word with double quote in normal mode nnoremap <leader>" ea"<esc>hbi"<esc>lel "Enclose current word with single quote in normal mode nnoremap <leader>' ea'<esc>hbi'<esc>lel "Enclose current word with angle brackets in normal mode nnoremap <leader>< ea><esc>hbi<<esc>lel "Align the character  function! AlignLines(alignChar)     let [ firstLine , firstColumn ] = getpos("'<")[1:2]     let [ lastLine  , lastColumn  ] = getpos("'>")[1:2]     let lineContent = getline( firstLine , lastLine )     let maxColumn = 0      for singleLine in lineContent         let currentColumn = stridx(singleLine , a:alignChar)         if currentColumn > maxColumn              let maxColumn = currentColumn         endif     endfor     let loop = firstLine      while loop <= lastLine         let currentColumn = stridx(getline(loop), a:alignChar)         "skip the blank line          if currentColumn != -1             let padString = repeat(" ",maxColumn - currentColumn )             execute "silent " . loop . 's/' . a:alignChar . '/' . padString . a:alignChar . '/'         endif         let loop = loop + 1     endwhile endfunction vnoremap <leader>a :<c-u>call AlignLines("")<Left><Left>
    转载请注明原文地址: https://ju.6miu.com/read-1309317.html
    最新回复(0)