diff --git a/README.md b/README.md index 12a5cd0..30e1cc2 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ :Secret! Disable secret view. + + <Plug>SecretToggle + Toggle secret view. + An area around the cursor is unhidden to enable you to see what you are typing. This can be the entire line, the current word, the current character, or it can be disabled completely. diff --git a/autoload/secret.vim b/autoload/secret.vim index 3df7667..b0f6cf3 100644 --- a/autoload/secret.vim +++ b/autoload/secret.vim @@ -164,3 +164,11 @@ function! secret#secret(enable, ...) call s:disable() endif endfunction + +function! secret#toggle() + if !exists('w:secret_state') || !has_key(w:secret_state, bufnr()) + call secret#secret(1) + else + call secret#secret(0) + endif +endfunction diff --git a/doc/secret.txt b/doc/secret.txt index 485ffdf..4e9fbc4 100644 --- a/doc/secret.txt +++ b/doc/secret.txt @@ -64,12 +64,20 @@ g:secret_timeout_insert Hide entire buffer after 'updatetime' milliseconds ============================================================================== MAPPINGS *secret-mappings* +Secret view mappings~ *g:secret_quickhide* -g:secret_quickhide Hide entire buffer until the cursor is moved. Set this - to a key sequence string: > +g:secret_quickhide Hide entire buffer until the cursor is moved. + Set this to a key sequence string: > let g:secret_quickhide = 'q' +Global mappings~ + *SecretToggle* +SecretToggle Toggle secret view. + mappings are used like this: > + + nmap s SecretToggle + ============================================================================== HIGHLIGHTING *secret-highlight* *SecretVisible* diff --git a/plugin/secret.vim b/plugin/secret.vim index bb5b091..d39c4b7 100644 --- a/plugin/secret.vim +++ b/plugin/secret.vim @@ -1,4 +1,5 @@ command! -bang -nargs=* Secret call secret#secret(1, ) +nmap SecretToggle :call secret#toggle() if !exists('g:secret_cchar') let g:secret_cchar = '•' diff --git a/test/test.vader b/test/test.vader index 89b18ff..ce3f135 100644 --- a/test/test.vader +++ b/test/test.vader @@ -249,3 +249,9 @@ Execute (quickhide mapping, moving around): AssertSyntax '••••• •••••', '••••• ••• ••••' Secret! AssertEqual maparg('q'), '' + +Execute (toggle mapping): + nmap s SecretToggle + AssertSyntax ' ', ' ' + normal s + AssertSyntax '----- •••••', '••••• ••• ••••'