是否可以使用Vim命令执行此操作?
[] =光标正常模式
[=光标插入模式
之前
Text []
Run Code Online (Sandbox Code Playgroud)
后
Text
[
Run Code Online (Sandbox Code Playgroud)
之前
Text []
Run Code Online (Sandbox Code Playgroud)
后
[
Text
Run Code Online (Sandbox Code Playgroud)
我已经使用以下映射更改了/ 的[count]行为.我认为这样做你想要的:oO
" o/O Start insert mode with [count] blank lines.
" The default behavior repeats the insertion [count]
" times, which is not so useful.
function! s:NewLineInsertExpr( isUndoCount, command )
if ! v:count
return a:command
endif
let l:reverse = { 'o': 'O', 'O' : 'o' }
" First insert a temporary '$' marker at the next line (which is necessary
" to keep the indent from the current line), then insert <count> empty lines
" in between. Finally, go back to the previously inserted temporary '$' and
" enter insert mode by substituting this character.
" Note: <C-\><C-n> prevents a move back into insert mode when triggered via
" |i_CTRL-O|.
return (a:isUndoCount && v:count ? "\<C-\>\<C-n>" : '') .
\ a:command . "$\<Esc>m`" .
\ v:count . l:reverse[a:command] . "\<Esc>" .
\ 'g``"_s'
endfunction
nnoremap <silent> <expr> o <SID>NewLineInsertExpr(1, 'o')
nnoremap <silent> <expr> O <SID>NewLineInsertExpr(1, 'O')
Run Code Online (Sandbox Code Playgroud)
这两个映射有帮助吗?
nnoremap <leader>O O<ESC>O
nnoremap <leader>o o<cr>
Run Code Online (Sandbox Code Playgroud)
第一个by pressing <leader>O将在当前行上方添加两个空行,并使您进入INSERT模式.第二个by pressing <leader>o将在当前后添加两行.