Skip to content

Commit

Permalink
Update [[ and ]] mappings
Browse files Browse the repository at this point in the history
1. Add support for setext style headings
2. Use the 's' flag in search() to set the ' mark instead of using m'
3. Fix the guard
  • Loading branch information
gpanders authored and tpope committed Feb 1, 2020
1 parent 6c4c60f commit f35c43c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ else
let b:undo_ftplugin = "setl cms< com< fo< flp<"
endif

if !exists("g:no_plugin_maps") || !exists("g:no_markdown_maps")
nnoremap <silent><buffer> [[ m':call search('^#\{1,5\}\s\+\S', "bW")<CR>
nnoremap <silent><buffer> ]] m':call search('^#\{1,5\}\s\+\S', "W")<CR>
xnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^#\{1,5\}\s\+\S', "bW")<CR>
xnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^#\{1,5\}\s\+\S', "W")<CR>
if !exists("g:no_plugin_maps") && !exists("g:no_markdown_maps")
nnoremap <silent><buffer> [[ :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
nnoremap <silent><buffer> ]] :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
let b:undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]'
endif

Expand Down

0 comments on commit f35c43c

Please sign in to comment.