Skip to content

Conversation

gjherbiet
Copy link
Contributor

This adds the --comment-non-required option to UltiSnips/generate.py with effect to:

  1. suppress the blank line between required and non-required options
  2. prefix a comment ('#') symbol before non-required options.

Before:

snippet add_host "Add a host (and alternatively a group) to the ansible-playbook in-memory inventory" b
ansible.builtin.add_host:
	name: ${1:# The hostname/ip of the host to add to the inventory, can include a colon and a port number.}

	groups: ${3:# The groups to add the hostname to.}
endsnippet

After:

snippet add_host "Add a host (and alternatively a group) to the ansible-playbook in-memory inventory" b
ansible.builtin.add_host:
	name: ${1:# The hostname/ip of the host to add to the inventory, can include a colon and a port number.}
	#groups: ${2:# The groups to add the hostname to.}
endsnippet

This is useful as all unused (left commented-out) non-required options can then be quickly removed in Vim with the following sequence:

{ V } " visually select the current pagraph = inserted module snippet
:'<,'>g/^\s\+#/d " command to delete all lines beginning with spaces/tabs and the comment symbol in current visual selection

@pearofducks
Copy link
Owner

Can you resolve the conflict here from #128 and then I'll bring this in too?

@gjherbiet
Copy link
Contributor Author

Conflict resolved. You can proceed with the merge. Thanks.

@pearofducks pearofducks merged commit f8c503c into pearofducks:master Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants