visual studio plugin for macro alignment - macros

how to easily format C++ macro defination?
my code is below:
#define SADSKKHDJJKSDF 1
#define FD 2
#define KJDSKJFD 3
what i want like this:
#define SADSKKHDJJKSDF 1
#define FD 2
#define KJDSKJFD 3
for now, i'm using vs2008 plubin "AStyle", it will help me a lot about my code excep macro.
yeah, who can help me, thx a lot

You can use Code Alignment plugin http://visualstudiogallery.msdn.microsoft.com/7179e851-a263-44b7-a177-1d31e33c84fd/
Here are the setup instructions http://www.codealignment.com/ForVisualStudio.html
Then you can select your text. Use "AlignByString" ans check "Align from caret position"

Related

VS Code, disable `grey` color on the codes inside #ifdef

As you can see in this image, some code (it is int aaa = 1) inside #ifdef (a preprocessor block) is grey, it is inconvenient to read when there is a lot of similar code. Is there a way to remove the grey color on it, and makes it same color like int aaa = 0 in the image?
The output in image is for C++ code, append the code here in case the pic cannot be shown:
#ifdef _DEBUG
int aaa = 0
#else
int aaa = 1
#endif
I had tried some configurations in workbench.colorCustomizations, but didn't find the right one.
The setting you are looking for is C_Cpp.dimInactiveRegions. You can put that in a settings.json file like this:
"C_Cpp.dimInactiveRegions": false
The setting's description:
Controls whether inactive preprocessor blocks are colored differently than active code. This setting has no effect if IntelliSense is disabled or if using the Default High Contrast theme.

visual studio code auto add space to special characters?

I am using some extensions like Monokai Pro, Prettier, Quokka, Tabnine AI, TODO highlight ... and here is my problem
I want to code a very simple code, like this
rest1.numGuests ??= 10;
and my VS code auto make this tobe like this one
rest1.numGuests ? ? = 10;
it makes my code to be errors.
I am searching how to fix this one but still do now know how to fix, could you please give me some advices ? Thank you very much for your time.

Eclipse C/C++ Formatter Line Wrapping or Indentation Problem When a Macro is a Function Parameter

I am having problem when I try to format C code in Atollic TrueSTUDIO for STM32 9.3.0. When a macro is a parameter of a function, line wrapping doesn't work. It is a bug or I couldn't find the correct setting in Formatter.
#define GPIO_PIN_7 ((uint16_t)0x0080U)
GPIO_InitAsOutput(&LED_D, GPIOC,
GPIO_PIN_7,
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
In the code above, GPIO_PIN_7 is the problem here. Line wrapping width is 80. When I press "CTRL+SHIFT+F", It should be look like this:
PIO_InitAsOutput(&LED_D, GPIOC, GPIO_PIN_7,
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
However, It doesn't change the format.
One other odd thing is that If I replace GPIO_PIN_7 with ((uint16_t)0x0080U), It is working and code becomes like below:
PIO_InitAsOutput(&LED_D, GPIOC, ((uint16_t)0x0080U),
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
What should I do to correct this behavior?
You just hit the Eclipse bug 459301. Until it's fixed you can just use formatter tags if you can use Eclipse 2019-03 with CDT 9.7.
//#formatter:off
PIO_InitAsOutput(&LED_D, GPIOC, GPIO_PIN_7, GPIO_OutputType_PushPull,
GPIO_Pull_None, GPIO_Speed_Low);
//#formatter:on

How to embed latex result to ODT file emacs org-mode?

In org-mode, try to push LaTex code to generate matrix like this
The code is like this:
#+BEGIN_SRC latex
\[ G_{x} = \left[ \begin{array}{ccc}
-1 & 0 & 1 \\
-2 & 0 & 2 \\
-1 & 0 & 1 \end{array} \right] {\hspace{2em}} G_{y} = \left[ \begin{array}{ccc}
-1 & -2 & -1 \\
0 & 0 & 0 \\
1 & 2 & 1 \end{array} \right] \]
#+END_SRC
But when I try to export ORG file to ODT document, the matrix are not presented. Do I need any options or configuration for my org-mode?
Thanks
Untested, but there are a couple of answers to this in the Org-mode manual, specifically they involve wrapping the snippet in \begin{equation}and \end{equation} rather than #+begin_src (which I think will result in embedding the source in the ODT), and setting an option (such as #+OPTIONS: tex:imagemagick) which will ask Org-mode to embed LaTeX as images.
http://orgmode.org/manual/Working-with-LaTeX-math-snippets.html#Working-with-LaTeX-math-snippets
Note: this may be specific to your version of Org-mode -- the exporter framework was significantly overhauled for 8.0 and I believe this documentation applies to Org-mode 8.0.

Different indent styles of Ocaml in Emacs

I am writing Ocaml code under Emacs. Currently, the indent style is like the following, that is, the code where a variable is defined by let is a little bit on the left of let.
let v = 5 in
Printf.printf "v= %d\n" v
I also see some files written by others, when I open them, the indent style is that the code is in the same column as let:
let v = 5 in
Printf.printf "v= %d\n" v
I think the second style looks better, does anyone know where I could setup Emacs so that my Emacs takes the second style?
Thank you very much!
You can also use ocp-indent which indents by default using the second style.
look to the 'tuareg-in-indent' setting, that sets how much ident should be done (0 to disable) - you can customize it with M-x customize-variable...
P.S. you can also look to 'tuareg-let-always-indent' variable...