From: Ciro Santilli 六四事件 法轮功 Date: Mon, 4 May 2015 14:25:43 +0000 (+0200) Subject: Merge pull request #205 from cirosantilli/readme-gx X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/fa17cb8df22137f311e3e87bd0be6cd5d17c8898?hp=1510e2cad59855b3bc4c48ec9a4c07c94e4bcb58 Merge pull request #205 from cirosantilli/readme-gx Document Markdown_OpenUrlUnderCursor --- diff --git a/README.md b/README.md index e92ae3b..770c625 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ Syntax highlighting, matching rules and mappings for [the original Markdown](http://daringfireball.net/projects/markdown/) and extensions. +1. [Installation](#installation) +1. [Options](#options) +1. [Mappings](#mappings) +1. [Commands](#commands) +1. [Credits](#credits) +1. [License](#license) + ## Installation If you use [Vundle](https://github.com/gmarik/vundle), add the following line to your `~/.vimrc`: @@ -125,6 +132,14 @@ The following work on normal and visual modes: - `]u`: go to parent header (Up). `Markdown_MoveToParentHeader` +This plugging follows the recommended Vim plugin mapping interface, so if you want to change the map `]u` to `asdf`, add to your `.vimrc`: + + map asdf Markdown_MoveToParentHeader + +To disable a map, use: + + map Markdown_MoveToParentHeader + ## Commands - `:HeaderDecrease`: diff --git a/ftplugin/mkd.vim b/ftplugin/mkd.vim index 6e04bd2..d67864a 100644 --- a/ftplugin/mkd.vim +++ b/ftplugin/mkd.vim @@ -510,6 +510,13 @@ function! s:OpenUrlUnderCursor() endif endfunction +function! s:MapNotHasmapto(lhs, rhs) + if !hasmapto('' . a:rhs) + execute 'nmap ' . a:lhs . ' ' . a:rhs + execute 'vmap ' . a:lhs . ' ' . a:rhs + endif +endfunction + call MapNormVis('Markdown_MoveToNextHeader', 'MoveToNextHeader') call MapNormVis('Markdown_MoveToPreviousHeader', 'MoveToPreviousHeader') call MapNormVis('Markdown_MoveToNextSiblingHeader', 'MoveToNextSiblingHeader') @@ -519,20 +526,13 @@ call MapNormVis('Markdown_MoveToCurHeader', 'MoveToCurHeader') nnoremap Markdown_OpenUrlUnderCursor :call OpenUrlUnderCursor() if !get(g:, 'vim_markdown_no_default_key_mappings', 0) - nmap ]] Markdown_MoveToNextHeader - nmap [[ Markdown_MoveToPreviousHeader - nmap ][ Markdown_MoveToNextSiblingHeader - nmap [] Markdown_MoveToPreviousSiblingHeader - nmap ]u Markdown_MoveToParentHeader - nmap ]c Markdown_MoveToCurHeader - nmap gx Markdown_OpenUrlUnderCursor - - vmap ]] Markdown_MoveToNextHeader - vmap [[ Markdown_MoveToPreviousHeader - vmap ][ Markdown_MoveToNextSiblingHeader - vmap [] Markdown_MoveToPreviousSiblingHeader - vmap ]u Markdown_MoveToParentHeader - vmap ]c Markdown_MoveToCurHeader + call MapNotHasmapto(']]', 'Markdown_MoveToNextHeader') + call MapNotHasmapto('[[', 'Markdown_MoveToPreviousHeader') + call MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader') + call MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader') + call MapNotHasmapto(']u', 'Markdown_MoveToParentHeader') + call MapNotHasmapto(']c', 'Markdown_MoveToCurHeader') + call MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor') endif command! -buffer -range=% HeaderDecrease call s:HeaderDecrease(, )