Skip to content

Instantly share code, notes, and snippets.

@dahu
Last active August 29, 2015 14:25
Show Gist options
  • Save dahu/18b48c70444d8078f7d7 to your computer and use it in GitHub Desktop.
Save dahu/18b48c70444d8078f7d7 to your computer and use it in GitHub Desktop.
emulating comments in vim's dict literals
" Barry Arthur, July 2015
" Kludge emulating comments in dict literals
" :-0 surprised?!
function! StripComments(comment_leader, dict)
return filter(a:dict, 'v:key !~ "^" . escape(a:comment_leader, "\"")')
endfunction
let x = StripComments('REM', {
\ 'a' : 1
\, 'REM This is a nasty workaround mimicking comments in dict literals' :-0
\, 'b' : 2
\, 'REM Duplicate keys are not tolerated within dict literals, hence the numbered comment keys' :-0
\, 'c' : 3
\, 'REM For the younger audience members, REM stands for "remark" and was the comment leader in BASIC' :-0
\, 'd' : 4
\})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment