honza/vim-snippets

how could delete the line about c.snippets?

iysheng opened this issue · 4 comments

I write a snip with c function code.

snippet rtfunc "RT-thread Function Header" 
/**
  * @brief $3
  * `!p 
snip.rv = ""
snip >> 2
args = get_args(t[2])
if args:
	for arg in args:
		snip.rv += '\n' + '  * @param' + ' ' + arg + ': '
snip << 2
 `
  * retval $5.
  */
${1}($2)
{
	${0}
}
endsnippet

the example code just like:

/**
  * @brief hello world
  * 
  * @param int a: 
  * @param int b: 
  * retval None.
  */
void hello_world(int a, int b)
{
	return;
}

I want to delete the line
between
* @brief hello world:
and
* @param int a:

to bring like

/**
  * @brief hello world
  * @param int a: 
  * @param int b: 
  * retval None.
  */
void hello_world(int a, int b)
{
	return;
}

is there any way to receive this goal?

I think it is as simple as moving the \n after the @params. I am not anywhere I can try it but see if that helps.

I think it is as simple as moving the \n after the @params. I am not anywhere I can try it but see if that helps.
After i change to:

/**
  * @brief 
  *   * @param
 unsigned char a:   * @param
 unsigned char b: 
  * retval .
  */
static int abc(unsigned char a, unsigned char b)
{
	
}

it get like as:

/**
  * @brief 
  *   * @param
 unsigned char a:   * @param
 unsigned char b: 
  * retval .
  */
static int abc(unsigned char a, unsigned char b)
{
	
}

😞

By after I meant at the end:

snip.rv += ' * @param' + ' ' + arg + ': ' + '\n'

By after I meant at the end:

It's stilled failed as,

/**
    * @brief
    *  * @param int d:-
    * @param int c:-

    * retval .
    */
  int a(int d, int c)
  {
  >---
  }

but after i change to

snippet rtfunc "RT-thread Function Header" 
/**
  * @brief $3`!p
snip.rv = ""
snip >> 2
args = get_args(t[2])
if args:
	for arg in args:
		snip.rv += '\n' + '  * @param' +  ' ' + arg + ': '
snip << 2
`
  * retval $5.
  */
${1}($2)
{
	${0}
}
endsnippet

It's ok now. thanks.