1

I want the code like this.

for (;;) {

}

But YASnippet always output this.

for (;;)
{

}

Is there a way to change the C++ style?

This is my .emacs file.

(setq c-default-style "stroustrup")

(add-to-list 'load-path "~/emacs/yasnippet/") (require 'yasnippet) (yas-global-mode 1)

Drew
  • 29,895
  • 7
  • 74
  • 104
Ian Zhou
  • 13
  • 2

1 Answers1

0

You'd just have to edit the snippet for yourself. It's located in snippets/cc-mode/for. Here's how mine looks like:

# -*- mode: snippet -*-
#name : for (...; ...; ...) { ... }
# --
for (unsigned int ${1:i}=0; $1<${2:N}; ++$1)$0

I insert the braces separately with a function from here, since sometimes you need braces and sometimes not.

Community
  • 1
  • 1
abo-abo
  • 20,038
  • 3
  • 50
  • 71