Skip to content

Commit

Permalink
map -> nmap; document "set defaults" in README
Browse files Browse the repository at this point in the history
Opening the peekaboo markbar with `map` keybindings breaks visual mode
selection and pending operators. Only open the peekaboo markbar from
normal mode, so that users can still use mark motions from visual mode,
operator pending mode, etc.

Document this in the README.
  • Loading branch information
Yilin-Yang committed Nov 10, 2018
1 parent 2f84a82 commit 98aeac7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ Quick Start
At a minimum, you should set some of the following keymappings in your `.vimrc`.

```vim
map <Leader>m <Plug>ToggleMarkbar
nmap <Leader>m <Plug>ToggleMarkbar
" the following are unneeded if ToggleMarkbar is mapped
map <Leader>mo <Plug>OpenMarkbar
map <Leader>mc <Plug>CloseMarkbar
nmap <Leader>mo <Plug>OpenMarkbar
nmap <Leader>mc <Plug>CloseMarkbar
```

These examples use the [leader key,](https://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file)
Expand Down Expand Up @@ -147,10 +147,6 @@ _jump to_ mark `a`.

By default, you can **jump to the selected mark** by pressing the `Enter` key.

As of the time of writing, **the peekaboo markbar is not compatible with visual
mode,** e.g. you can't press `V` to start a linewise selection, and then press
`'a` to select every line between that starting position and the mark `a`.

Customization
--------------------------------------------------------------------------------

Expand Down Expand Up @@ -182,9 +178,9 @@ let g:markbar_reset_mark_mapping = 'r'
let g:markbar_delete_mark_mapping = '<Del>'
" open/close markbar mappings
map <Leader>m <Plug>ToggleMarkbar
map <Leader>mo <Plug>OpenMarkbar
map <Leader>mc <Plug>CloseMarkbar
nmap <Leader>m <Plug>ToggleMarkbar
nmap <Leader>mo <Plug>OpenMarkbar
nmap <Leader>mc <Plug>CloseMarkbar
```

### Peekaboo Customization
Expand All @@ -205,6 +201,22 @@ let g:markbar_peekaboo_apostrophe_mapping = '<leader>a'
let g:markbar_peekaboo_backtick_mapping = '<leader>b'
```

Alternatively, if you want to set your own explicit mappings, you can set the
following options:

```vim
" leave peekaboo markbar enabled, but don't set default mappings
let g:markbar_set_default_peekaboo_mappings = v:false
nmap <leader>a <Plug>OpenMarkbarPeekabooApostrophe
nmap <leader>b <Plug>OpenMarkbarPeekabooBacktick
```

As of the time of writing, the peekaboo markbar isn't fully compatible with
operator-pending mode, visual mode, or select mode. For instance, setting `vmap
' <Plug>OpenMarkbarPeekabooApostrophe` will allow you to _open_ the
peekaboo markbar from visual mode, but doing so will cancel your visual selection.

If you want to disable the peekaboo markbar entirely, you can set
`g:markbar_enable_peekaboo` to `v:false`.

Expand Down
4 changes: 2 additions & 2 deletions plugin/vim-markbar.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ if markbar#settings#EnablePeekabooMarkbar()
noremap <silent> <Plug>OpenMarkbarPeekabooBacktick :call g:peekaboo_controller.backtick()<cr>
if markbar#settings#SetDefaultPeekabooMappings()
execute 'map <silent> '.markbar#settings#PeekabooApostropheMapping()
execute 'nmap <silent> '.markbar#settings#PeekabooApostropheMapping()
\ .' <Plug>OpenMarkbarPeekabooApostrophe'
execute 'map <silent> '.markbar#settings#PeekabooBacktickMapping()
execute 'nmap <silent> '.markbar#settings#PeekabooBacktickMapping()
\ .' <Plug>OpenMarkbarPeekabooBacktick'
endif
endif
Expand Down

0 comments on commit 98aeac7

Please sign in to comment.