Intuitive and repeatable line joining
- Downwards/upwards joining
- Cursor retaining
- Easy line counting
- Repeating actions (using vim-repeat)
If using vim-plug, add the following to vimrc
:
call plug#begin()
" ...
Plug 'tpope/vim-repeat' " Optional dependency, enables repetition with '.'
Plug 'awvalenti/vim-jk-join'
" ...
call plug#end()
For other plugin managers, please check their documentation, or take a look at native plugin system.
[count]J
joinscount
lines downwards, changing spaces[count]gJ
joinscount
lines downwards, preserving spaces[count]K
joinscount
lines upwards, changing spaces[count]gK
joinscount
lines upwards, preserving spaces.
repeats last join
You can skip the default mappings and map only what you want. Samples below.
Default mappings are: (note: k
in JkJoin
is lowercase)
nmap J <Plug>JkJoinJ
nmap gJ <Plug>JkJoinGJ
nmap K <Plug>JkJoinK
nmap gK <Plug>JkJoinGK
Only K
:
let g:jk_join_manual_mapping = v:true
nmap K <Plug>JkJoinK
Only gJ
and gK
:
let g:jk_join_manual_mapping = v:true
nmap gJ <Plug>JkJoinGJ
nmap gK <Plug>JkJoinGK
The K
feature, but mapped to gK
let g:jk_join_manual_mapping = v:true
nmap gK <Plug>JkJoinK
- Doesn't Vim already have
J
andgJ
? - Couldn't I simply
nnoremap K kJ
to haveK
?
Yep, but you'd lose:
5J
== 5 timesJ
(would act as 4 timesJJ
)5K
== 5 timesK
(would move 5 lines above and join once).
to repeat- Cursor retaining
If you find this plugin useful, please leave me a star up there ⭐!