mirror of
https://github.com/amix/vimrc
synced 2025-07-07 08:45:00 +08:00
- 添加自定义配置
- 配置打开目录树及最近文件快捷键 - 加入交换上下两行的插件 > 插件来源[cnblog](https://blog.csdn.net/dowemo/article/details/78425352)
This commit is contained in:
33
my_plugins/swap_lines/plugin/swap_lines.vim
Normal file
33
my_plugins/swap_lines/plugin/swap_lines.vim
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
function! s:swap_lines(n1, n2)
|
||||
let line1 = getline(a:n1)
|
||||
let line2 = getline(a:n2)
|
||||
call setline(a:n1, line2)
|
||||
call setline(a:n2, line1)
|
||||
endfunction
|
||||
|
||||
function! s:swap_up()
|
||||
let n = line('.')
|
||||
if n == 1
|
||||
return
|
||||
endif
|
||||
|
||||
call s:swap_lines(n, n - 1)
|
||||
exec n - 1
|
||||
endfunction
|
||||
|
||||
function! s:swap_down()
|
||||
let n = line('.')
|
||||
if n == line('$')
|
||||
return
|
||||
endif
|
||||
|
||||
call s:swap_lines(n, n + 1)
|
||||
exec n + 1
|
||||
endfunction
|
||||
|
||||
nmap <silent> <c-k> :call <SID>swap_up()<CR>
|
||||
nmap <silent> <c-j> :call <SID>swap_down()<CR>
|
||||
|
||||
imap <silent> <c-k> :call <SID>swap_up()<CR>
|
||||
imap <silent> <c-j> :call <SID>swap_down()<CR>
|
Reference in New Issue
Block a user