vim-paraglide is a plugin to make navigating paragraphs easier.
The standard }
and {
paragraph motions jump to the blank lines before and after a paragraph, respectively, rather than to the start and end of the paragraph. If you want to change this behavior, you have to edit the somewhat-arcane nroff macros of the'paragraphs'
options.
The standard paragraph motions also don't work very well with blocks, such as when you want to select a vertical column in a markdown table. vim-paraglide provides flexible mappings for most use cases around paragraph navigation.
Default keybinding: <down>
/<up>
.
Default keybindings:
<s-down>
/<s-up>
for top edges}
/{
for bottom edges (similar to default paragraph motions)
Tip: hold down shift
and use the arrow keys to move across paragraphs quickly, if you're just navigating through the file.
Default keybinding: g<down>
/g<up>
.
This works by ignoring characters to the left of the cursor column when searching for a paragraph break.
Key | Mapping |
---|---|
<down> |
Jump to next edge |
<up> |
Jump to previous edge |
<s-down> (shift-down) |
Jump to next edge (top only) |
<s-up> (shift-up) |
Jump to previous edge (top only) |
} |
Jump to next edge (bottom only) |
{ |
Jump to previous edge (bottom only) |
g<down> |
Block-wise jump to next edge |
g<up> |
Block-wise jump to previous edge |
To set up a custom mapping, add the following to your .vimrc:
" Use 'gj' and 'gk' to navigate paragraphs instead of the arrow keys.
noremap <silent> gj <Plug>ParaglideDownAny
noremap <silent> gk <Plug>ParaglideUpAny
To see the full list of available keys, do:
:map <Plug>Paraglide <ENTER>
Setting | Purpose | Default |
---|---|---|
g:paraglide_default_maps |
Whether to install the default mappings. | 1 |
g:paraglide_modify_jumplist |
Whether to add jumps to the window jumplist. | 1 |
g:paraglide_wrap |
Whether to wrap around to the top or bottom while jumping. | 0 |
If you like the idea of this plugin, you may also be interested in:
- targets.vim - Vim plugin that provides additional text objects
- vim-easymotion - Vim motions on speed!
- vim-edgemotion - Move to the edge!