Advanced indent settings in Visual Studio - plugins

I'm using VS2013 and I'd like to change indentation. However, Visual's settings aren't enough for me. I'd like it to auto indent it like this:
int function()
{
int a=1;
while (a)
{
if(a>0)
{
a=0;
return;
}
}
}
Are there any plugins, or anything like this to help me with indentation?

Related

why hover doesn't work on Linux using VSCode after the latest release of VSCode(1.59.1)?

I am actually trying to make a VSCode extension that will provide hover functionality. I had managed to make it work but since the last release of VSCode (1.59.1) it doesn't work anymore on Linux computers (have tested on Ubuntu and CentOs), but still works on Windows and MacOS. Here is my client js file (./client/extension.js):
const vscode = require('vscode');
function activate(context) {
console.log('Congratulations, your extension of YALES2 is now active!');
console.warn('Congratulations, your extension of YALES2 is now active!')
let disposable = vscode.commands.registerCommand('extension.mamar', () => {
vscode.window.showInformationMessage("Hover");
});
context.subscriptions.push(disposable);
disposable = vscode.languages.registerHoverProvider('yales2test', {
provideHover(document, position, token) {
const range = document.getWordRangeAtPosition(position);
const word = document.getText(range);
if (word=="ABSORBING_BOUNDARIES") {
return new vscode.Hover({ language: "yales2test", value: 'Message to show on Hover'});
}
}
});
context.subscriptions.push(disposable)
}
function deactivate() { }
module.exports = {
activate,
deactivate
}
And on my package.json I have:
"activationEvents": [
"onCommand:extension.mamar",
"onLanguage:yales2test"
],
"main": "./client/extension.js",
"contributes": {
"capabilities": {
"hoverProvider": "true"
}
I also tried to downgrade VSCode to 1.58.2 and there the hover works!
Would anyone know why it doesn't work anymore on Linux when using VSCode 1.59.1, please?
The problem was the length of my extension.js since it had a huge number of if ... else if... resulting to an exceed of memory! So always think to optimize your code!

How do i change the way visual studio code auto corrects curly braces?

I prefer my curly braces looking like this:
function eg()
{
}
But when I try to format my code, vscode auto corrects to this:
function eg() {
}
Is there any plugins that I can download or setting that I can tweak to change this?
Try :
"javascript.format.placeOpenBraceOnNewLineForFunctions": true;
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true;
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true;
"typescript.format.placeOpenBraceOnNewLineForFunctions": true;

Folding regions in visual studio code v1.17 not working

I am using visual studio code v1.17 and I am doing development in pure javascript for chrome extension development. Visual studio code v1.17 supports region folding facility for javascript and several other languages.
So, I created one class inside one .js file and write getter setter methods inside it. like
//#region EmailObj
get EmailObj() {
this._EmailObj = localStorage.getItem("CurrentEmail");
try {
this._EmailObj = JSON.parse(this._EmailObj);
}
catch(e) {
this._EmailObj = null;
}
return this._EmailObj;
}
set EmailObj(newValue) {
this._EmailObj = JSON.stringify(newValue);
localStorage.setItem("CurrentEmail", this._EmailObj)
}
remove_EmailObj() {
this._EmailObj = null;
localStorage.removeItem("CurrentEmail");
}
//#endregion EmailObj
Now as per documentation stated at https://code.visualstudio.com/updates/v1_17#_folding-regions. Plus (+) icon should be shown near #region and #endregion sections (so, I can show / hide particular region) but it is not showing there.
So, somebody help me that what I am missing here?
I updated VS code to 1.17.2 and its now working at my side.

how to use text editors in Eclipse Mars programmatically, using the compatiblity layer?

I am using the 3.x-4.x compatibility layer and I'm attempting to open and use editors. Our existing code looks like this in the class that implements IPartListener2:
public void partOpened(IWorkbenchPartReference partRef) {
if (partRef instanceof IEditorReference) {
//force editor area visible
partRef.getPage().setEditorAreaVisible(true);
// if the editors are currently minimimized and we try to maximize them, then we'll cause a bug.
if (partRef.getPage().getPartState(partRef) == IWorkbenchPage.STATE_MINIMIZED) {
return; // so exit here
}
//check preferences
final boolean maximized = EnterpriseManager.isMaximized();
if (maximized) {
partRef.getPage().setPartState(partRef, 1);
}
}
}
The problem is now whenever an editor is opened in Mars, it doesn't open maximized as a tab on the page layout as before, but in a much smaller window size.
Also, selecting the Restore Icon on an open editor's rule bar causes erratic positioning of the editor with one section of the editor in one part of the layout and other sections displaying in other areas of the page layout.
How am I to implement correct, predictable usage of editors with the compatibility layer?
Just guessing but it may be that Eclipse 4 does not like the setEditorAreaActive and setPartState methods being called while partOpened is being processed. You could try using Display.asyncExec to delay calling these until after the partOpened code has completed.
Something like:
public void partOpened(final IWorkbenchPartReference partRef) {
Display.getDefault().asyncExec(new Runnable()
{
#Override
public void run()
{
if (partRef instanceof IEditorReference) {
//force editor area visible
partRef.getPage().setEditorAreaVisible(true);
// if the editors are currently minimimized and we try to maximize them, then we'll cause a bug.
if (partRef.getPage().getPartState(partRef) == IWorkbenchPage.STATE_MINIMIZED) {
return; // so exit here
}
//check preferences
final boolean maximized = EnterpriseManager.isMaximized();
if (maximized) {
partRef.getPage().setPartState(partRef, IWorkbenchPage.STATE_MAXIMIZED);
}
}
}
});
}

NetBeans IDE - How do i make indent lines, where i have largest and longest if while for brakets, can not find start and end now

I have my Java/C code running in NetBeans IDE. Where i have some mess algorithms which is like largest/longest something like following:
if () {
while() {
for() {
}
}
} elseif( ) {
for() {
while() {
for() {
}
}
}
} elseif( ) {
do {
for () {
if() {
} else {
}
}
} while() ;
} elseif( ) {
switch() {
if(a.starsWith()) {
for() {
do {
for() {
if() {
} elseif() {
} else {
switch() { }
}
}
} while();
}
}
}
} elseif( ) {
} elseif( ) {
} elseif( ) {
}
Therefore, to find out how do i get this following type of indent highlighted lines?
The vertical lines you see in Notepad++ are not available in NetBeans. But I didn't try the new NetBeans 7.2 beta yet...
From version of Netbeans 8.0 indent lines are available out of the box.
In netbeans 8.1 tools>options>Fonts&Colors>Category>Indent Guide Lines then change Forground to your likeing.
Not sure what your question is, and the image you attached is too small:-(
Anyways, you can specify the type of indent you want NetBeans to use for your code in Preferences -> Editor -> Formatting. You can choose the indents to be tabs, or (recommended) spaces. There is a box where you type in the number of spaces you want per tab.
Also, you can make NetBeans format the code automatically for you, under Source -> Format.
Hope this helps!
Are you looking to highlight lines or just indent your code correctly?
If it is the latter, select all your code, then from the menu bar select Source -> Format.
That should resolve the issue.