Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce triple bang syntax to remove triggers #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions autoload/snipMate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ fun! snipMate#ReadSnippetsFile(file) abort
if line[:6] == 'snippet'
let inSnip = 1
let bang = (line[7] == '!')
if bang
if bang "!!
let bang += line[8] == '!'
endif
if bang "!!!
let bang += line[9] == '!'
endif
let trigger = strpart(line, 8 + bang)
let name = ''
let space = stridx(trigger, ' ') + 1
Expand Down Expand Up @@ -314,7 +317,13 @@ endfunction

function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort
let d = a:dict
if a:bang == 2
if a:bang == 3
unlet! d[a:trigger][a:path]
if len(d[a:trigger]) == 0
unlet! d[a:trigger]
endif
return
elseif a:bang == 2
unlet! d[a:trigger]
return
elseif !has_key(d, a:trigger) || a:bang == 1
Expand Down
3 changes: 3 additions & 0 deletions doc/SnipMate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ overridden on a per-snippet basis by defining the snippet with a bang (!): >
Two bangs will remove the trigger entirely from SnipMate's lookup. In this
case any snippet text is unused.

Three bangs will remove the trigger from the current scope. In this
case any snippet text is unused.

Note: Hard tabs in the expansion text are required. When the snippet is
expanded in the text and 'expandtab' is set, each tab will be replaced with
spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise.
Expand Down