Visual Studio Code surround/wrap selected with custom function (Python) - python-3.x

Android Studio Code (and I assume many other great editors) gives the option to select code and wrap either a custom function around or the most commonly used functions. For the custom functions, a window with a text line could appear in which you write the wrapping function.
Is there any comparable solution for Python in Visual Studio Code? It would increase the workflow significantly .
"Hello" -> print("Hello") # Functions with a single parameter are wrapped around the selected text "Hello"
3+10 -> np.random.uniform(3+10,,) # The function is filled as much as possible with selected values
3+10,5,3 -> np.random.uniform(3+10,5,3) # Tuples are inserted directly into the function
The answer to the common question
Visual Studio Code Surround With
brought the answer that it is language dependent and I a solutions for Javascript and for C in VisualCode.

Related

How to fold arrays in the editor Android Studio

I'm trying to set change the Android Studio editor settings so that when I press format it doesn't place each element in the array in a new line as seen on this screenshot:
Android Studio array
But folds it nicely, like Rider does seen in the following screenshot:
Rider array
Any ideas?
It seems to me the difference is due to languages (Kotlin vs Java), and not IDEs (Android Studio vs Rider). The culprit of your formatting problem is Kotlin's language feature to use arrayOf() function instead of array initializer to create arrays with known list of elements. Elements in arrayOf(...) are considered Function call arguments, so you may want to look at the corresponding setting.
In File -> Settings -> Editor -> Code Style -> Kotlin -> Wrappings and Braces, the default value of Function call arguments is Do not wrap. This means the formatter respects your code and will never add new lines between arguments. Option Wrap if long means if one line exceeds hard wrap limit (default: 120 chars), \n or \n\r will be inserted. I think switching to this option is one thing you can do but wrapping at 120 chars may be too long for arrays. The other options, in my opinion, don't help much in your case.
By comparsion, Java has an extra Array initializer setting in Wrappings and Braces section.
As I have said, the formatter respects your code. Since "one element in one line" doesn't violate your wrapping rule, your code doesn't get reformatted. You can manually edit your code by searching and replacing (CTRL + R on Windows, possibly COMMAND + R on macOS) related lines using regular expressions :-)

VS Code Flutter shortcuts equivalent to Android Studio Flutter

I am looking for a few things to improve my productivity, Android Studio has these features and it really sped up my work, if you know any of these please share.
Ctrl+Shift+Space equivalent in VS Code Flutter. What it did in Android Studio was auto complete a statement. For example if I typed in if and then hit Ctrl+Shift+Space, the if condition code block would be completed for me automatically with () and {} after it, with putting the cursor within the condition.
Code snippets for things like for loops. On Android Studio you could type in iter and then Tab, it would create for (var _ in ) {} and automatically jump to both variables to fill their names on two Enter keystrokes.
These were great for me, please share if these exist in VS Code, as I understand it is supposed to be superior.
You should install dart extension for VSCode.
In order to prioritize the extension snippets and have these ones for the first suggestion, go to File/Settings/Text Editor/Suggestions and set Snippet Suggestions to top. Now it looks like

Visual Paradigm line break at method parameters

I have to make a documentation for my program, and that documentation have to contains class diagrams too.
My problem is, some method has too many parameters, and it makes the class diagram very long horizontally. And these large diagrams doesn't fit in the documentation.
Is there any way to break the line of the parameters? (I tried ctrl+enter) So the method will take place two lines, and it won't be that large horizontally.
How to resize the class elements in VP
For already existing classes:
Right click on the class - not on a class element.
On Popup menu choose Presentation Options -> Configure Class Presentation Options
Check Wrap Members , OK
Change the width of the class box and be happy.
For new classes from now on:
Tools-> Project Options->Diagramming->Class->Presentation
Check Wrap class Member, OK/Apply.
If you don't see some options
Go into Tools -> Application Options -> General -> Environment, check Advanced UI mode, apply and restart the whole application.
You can also divide a line by hand, using Alt+Enter
The Visual Paradigm documentation says to use Ctrl+Enter but on a OS X at least, it is opt+return.
Note that experience has shown that if you hold down opt too long before pressing return it will activate a menu shortcut mode*. When this happens it also leaves edit mode so hitting return at that point has no effect.
So on OS X be sure to hit return immediately after pressing down opt.
You can change the key sequence for line breaks on OS X by going to Windows -> Application Options -> Diagramming, and changing the drop-down value for "Create new line key".
*I tried several different Google searches to find the Visual Paradigm documentation that explains this "mode" but didn't have any luck. I invented the term "menu shortcut mode" to describe it.

How to display native types when debugging in VS2012 for mixed mode C++/CLI MFC app

Possible duplicate of this question.
I have a MFC project that uses /clr switch and some C++/CLI code to use a .Net component. Originally this was on VS2005.
On upgrading to VS2012 Update 2, during debugging, no values or types were shown for native data types. I learned that a new mechanism for native data type visualization (natvis) was introduced in VS2010 and extended / enhanced in VS2012. Following the information on that page, I unchecked Managed C++ Compatibility Mode and C/C++ edit and continue. After this, breakpoints became disabled and stopped being hit. Using "Only Managed" debugger, the breakpoints were hit but no values were shown.
Finally, I used "mixed" debugger and used __debugbreak() to force a break. This resulted in only integer values being shown ONLY if they are local autos; and data types were picked up correctly. However, std::string or CString values are not shown and instead their type is shown in value column. Similarly, pointers, class members, or functions argument values are not shown and type information, Undefined value, or out of scope is shown in the value column.
The behavior is consistent across autos, locals and watch windows as well as mouse hover on symbols.
How do I get the native data types to display their values during debugging in VS2012 mixed mode C++/CLI MFC application.
I have read this question and verified that all symbols have been loaded in modules window.
Apparently, Microsoft is aware of the issue and the upcoming CTP of Update 3 should fix it.
Additionally, why do I need to use __debugbreak()?
A couple of days ago, Microsoft released a Visual Studio Service Pack 3 RC which may help (installing it myself right now). Here is the link: http://www.microsoft.com/en-us/download/details.aspx?id=38832
Re-install Visual Studio 2012 and do not apply Service Pack 2.

Is there a way in Visual Studio to specify what a template class (new class) is going to look like?

I'm a long time Eclipse user trying to learn to Visual Studio. I know that Eclipse had Code Templates that would allow you to build classes with certain comments and formatting already added for a class.
For example:
Auto placing the copyright for the code at the top of the file
Who created the file
Predefined Comments,
etc...
Does Visual Studio 2005 have any functionality like this?
It depends. Visual Studio has a built-in code snippets manager that lets you do things like this to at least a degree (i.e., if you insert a code snippet, it'll be formatted as the snippet specifies, but if you write the same code manually, it won't). Also note that there are limitations on the languages with which you can use code snippets.
Outside of that, most of the major add-ins for VS (e.g., Visual Assist-X) provide their own ability to store and insert bits of code, formatted as you specify. Most of these provide at least some features missing from the built-in snippets manager such as working with other languages or being easier to access (along with quite a few other things -- IMO, VS borders on completely unusable without VA-X).
I would recommend looking at item and project templates in Visual Studio, which sound like what you're looking for. But, in your particular case (C++ development), it doesn't look like this is available to you.
The following MSDN article refers to VS templates, and mentions that for Visual C++ projects, that the template architecture isn't supported. Instead, there's information on creating custom wizards for your project and classes, which may give you the flexibility that you need. Sounds like it'll do what you want it to do, but it's much more work than it would be if you could use an item template for including basic comment structure for a default class file.
http://msdn.microsoft.com/en-us/library/6db0hwky%28VS.80%29.aspx

Resources