Visual Studio Code going down to line automatically - ide

I am using Brackets at the moment i want to switch to Visual Stuido Code but some features of Brackets are very usefull.
One of them, i use the editor narrowly, Brackets going under line automatically if it is not fit the line, but Visual Studio Code does not.
And second one also is when i design a html i can see the differences in live preview, is it possible to see it in Visual Stuido Code also?
Visual Studio Code
Brackets

You want to enable the Word Wrap in Visual Studio Code.
Go to View -> Toggle Word Wrap.
Live Preview is actually possible in every editor you use. Today's devs use task automators like Gulp or Grunt, so they are not attached to specific editor like Brackets.
Using Gulp (or Grunt) you can set up a task that will watch your files for changes and then do specific actions, like reload the page, recompile Sass files etc.
You can find more here:
https://www.youtube.com/watch?v=r5fvdIa0ETk

Related

How to google from the context menu of the Visual Studio 2015 code editor

how can I modify Visual Studio 2015 to be able to search the internet (my fav search engine happens to be google) from the context menu in the code editor?
Ideally, I would like it to open as a new tab in my (default) external browser, because the internal web browser is still...lacking, shall we say?
I found one extension "web search" for older VS, but I have found no extension that works with VS 2015. I found no article that still works.
For comparison, when you're in Chrome, you can select some text, right click and say Search Google for 'what you selected'.
I think this would be handy when learning new technologies from a project that uses those technologies, or just for help.
Ok this turned out to be fairly easy. I just added a tool to Tools, External Tools
Command: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Arguments: https://www.google.com/?gws_rd=ssl#newwindow=1&safe=active&q=%22$(CurText)%22
I enclosed the $(CurText) variable around quotes (%22) so that it would search on the exact phrase.
Then, to make it more accessible and actually put it in the context menu (and other places), I clicked the Move Up button to make it the first command, then customized the Standard toolbar to include Tools.External Command 1. I also added it to Other Context Menus | Html Context and Editor Context Menus | Code Window
Then I also went into Tools, Options, Keyboard and associated Tools.ExternalCommand1 with Alt+G
IMPORTANT: Because Visual Studio (still, in 2015) doesn't save some modifications to the IDE until it shuts down, you need to shut down all other instances of VS and then lastly shut down the instance that you used to enact these IDE modifications for them to "stick". And, if VS 2015 is like previous versions, be prepared for the menu / toolbar modifications to simply go away one day, at which point you'll just have to redo them.

Resharper live templates in sql files

I created live template for creation of a stored procedure and I set availability in *.sql files. But when I'm in SQL file I don't have possibility to use live template by typing live template shortcut. I know that I have to change some setting in Visual Studio or in Resharper but I didn't find anything. Do you have any idea about that? I'm using VS 2013 and Resharper 8. Thank you.
Custom live templates should be able to work in .sql files.
You don't mention how you set your live template up, but here is how I acheived this with Visual Studio 2013 and ReSharper 8.2.
The example should allow you to type sf + TAB and get a select * from $TABLE$ template inside of a .sql file.
Go to ReSharper's Template Explorer via RESHARPER -> Templates Explorer...
Make sure you are on the "Live Templates" tab (the 1st one) of the Templates Explorer.
Under "Scopes" on the left side make sure "Global" is selected.
Click the new icon to bring up the template editor.
Add your template shortcut keys sf.
Add your template SELECT * FROM $TABLE$.
On the right side of the template editor window, select the link next to "Availability".
In the "Select Scopes" window that comes up, uncheck "Everywhere" and expand "In files matching".
Use the File mask *.sql
OK out and save your template.
The sf template should now be available in .sql files.
If you've followed these steps and it's still not working, you may have keyboard shortcut conflicts with another plugin. Consider reinstalling or repairing ReSharper or resetting the keyboard shortcuts via the RESHARPER -> Options -> Keybaord & Menus screen.
ReSharper's Live Templates only work in file formats that ReSharper supports, since Live Templates rely on other ReSharper features that need to understand languages, such as auto-formatting, name shortening and auto-imports and availability in scope. Also, Live Templates are inserted by selecting the item from ReSharper's code completion windows - if there's no code completion, there can't be any Live Templates.
Since ReSharper doesn't know about .sql files, you don't get Live Templates.

VS 2010 adding spaces at line end in AssemblyInfo.vb

I'm working in VB in Visual Studio 2010, trying to keep the lines in my AssemblyInfo.vb file clear of extra whitespace at the end. I track my projects with git using GitHub's Windows client and the powershell environment it ships with, so when I do a git diff I get red marks wherever there's erroneous whitespace.
Basically what I've found is that if I remove the whitespace in Visual Studio and save the file, it comes back. If I remove it in Notepad++, save, and reopen it in Visual Studio, the whitespace stays gone. After that, as soon as I change anything on a line, Visual Studio adds a space to the end of each line that I've changed which happens to end with > otherwise. If I change the end of the tag to />, it doesn't add the space, but of course that doesn't compile.
I've dug through the Text Editor settings for Basic, XML, and All Languages, but don't see any setting specific to this. Is there one I'm missing, or should I plan on using notepad for version changes? I'll also mention that I have Visual Studio 2012 on my personal machine, and it doesn't seem to do this there.
Is there any reason why you cannot use project properties?
Ah, found it. For future reference, it's part of "Pretty listing (reformatting) of code" in Text Editor > Basic > VB Specific. Thought I had that turned off already.

Move line Up/Down shortcut in Visual Studio 2012

In VS2010 I had a shortcut set up Alt+Up/Down to move lines of code up or down, just like I used to have in Eclipse in my Java days.
Now since Power Tools and macros (which is how I set up this shortcut in VS2010) are not available in VS2012, how do I get this to work?
I've seen somebody mentioned that Resharper can do this, but for the love of fire and water, I can't find the command names in the list of commands that can do that.
I have tried ReSharper_MoveUp/MoveDown and that does not move lines up/down:
This moves blocks of text up and down. I just want line-by-line up or down, no fancy logic there.
Before
After ALT+Up (when cursor is on WriteLine line) I would like to see this:
I have seen these threads: What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?, Visual Studio: hotkeys to move line up/down and move through recent changes, but none of the suggested solutions work in VS2012.
Any other ideas?
UPD 7 Nov 2012: . Extensions are catching up with Visual Studio 2012. Now I know at least 3 extensions that provide this functionality:
MoveLine Extension. Link provided by Carl G
Move Line Extension with modifications to 2010 version. By gius
Productivity Power Tools 2012. Have not actually tried this, but this blog post states it does the line move up/down
UPD 15 Nov 2012: Just stumbled across another extension that claims it does what is required here. Have not tried it though: LineMan Extension
UPD 10 May 2015 Just installed VS2015 RC and this is built-in already:
For those who arrived on this question using Visual Studio 2013 or above, the feature is built right into the program. Just use AltUp and AltDown to move the line with your cursor—or the selected lines—up and down.
If you wish to rebind it in Tools > Options > Environment > Keyboard, the keys are Edit.MoveSelectedLinesUp and Edit.MoveSelectedLinesDown. You may need to remove your new combination from other existing keys first.
Update: huzzah, Productivity PowerTools VS2012 is now available and offers this functionality (along with another personal favorite, Tools.AddEndTokenAtTheEnd.)
MoveLine Extension (compatible with VS 2012; I had to manually restart my VS in order to see the commands in VS's keyboard shortcut tool.)
Install ReSharper.
Open Tools -> Options -> Environment -> Keyboard (as shown in a picture)
Find "ReSharper.ReSharper_MoveUp"
In "Use new shortcut in:" choose: "Text Editor"
Click in "Press shortcut keys:" and press your shortcut (for example Alt+ArrowUp)
Press "Assign" button
Same with with "ReSharper.ReSharper_MoveDown"
P.S. Works fine for single lines and multiple selected lines, but removes selection after moved 1 line. Hope there are way to move multiple lines multiple times in one selection.
If you have Resharper, then you can hit Ctrl + Shift + Alt + ↑ to move the current line up. or Ctrl + Shift + Alt + ↓ to move one line down.
This works in VS 2012 Premium with Visual Studio keyboard scheme in Resharper 7 (7.0.97.60 to
be precise).
Edit: This is mapped to 'ReSharper.ReSharper_MoveUp'/'MoveDown' commands.
In Visual Studio 2017(atleast) I have below
You can use Move Line Command extension.
Just follow formula349's comment:
I was able to get this working with 2012 as-is.
Rename the package to .zip and unzip all files into a folder. Edit the extension.vsixmanifest file and look for the SupportedProducts XML node. Change the Version="10.0" to Version="11.0".
Re-zip the folder contents and rename back to .vsix. Works great!
While a lot of people seem to be recommending misc. Visual Studio Extensions and Resharper, I would like to point out there is a native hotkey that accomplishes this goal. I came to this question trying to find the answer, as my Resharper replaced my default hotkeys with their MoveUp and MoveDown versions.
And while Resharper's hotkeys do move things up and down, they are not what the original poster are looking for, and they are not what I wanted. These hotkeys move methods and blocks of code, not individual lines.
Visual studio has two hotkey commands to move your selected lines upwards or downwards.
These hotkeys are:
Edit.MoveSelectedLinesDown
Edit.MoveSelectedLinesUp
I am using Visual Studio 2013 however, so I am unaware if these exist in an older version. If 2012 does not have these hotkeys then perhaps an extension is the only solution.
Either way, I had an issue locating the exact hotkey within visual studio's list and it took me a good while to find these, so I hope that my solution manages to help someone else in a similar situation to my own.
Shift+Del and then Ctrl+V
Shift+Del does the cut (same as Ctrl+X) operation on the current line on which cursor is positioned.
Then you can use Ctrl+V to paste it at any place you like.
Good thing is that you don't need to select the complete current line, just the cursor needs to be positioned on the line.
One downside to using this shortcut is that you won't be able to see the line moving ( up or down ) lively in front of your eyes.
ReSharper's move up and move down shortcuts are smart - instead of just moving the current line (which can easily result in broken code), it will move the current statement up and down in the list of statements that make up the method body. This is much more powerful than just moving a single line of code.
But this doesn't help you get your statement inside the if block. Here you need to do one of two things.
Firstly, move the statement above the if block, then use Ctrl+Shift+Alt+Right to push it down in scope. The statement will now be inside the if block, and you can use up and down to move it around in there. You can also use Ctrl+Shift+Alt+Left to pull it up in scope, outside of the if block.
Alternatively, you can put the text caret on the outside of the closing brace of the if block and use Ctrl+Shift+Alt+Down to move the brace down, stepping over following statements, including them inside the if block.
These keys can do a lot more than just move a single statement. If you put the text caret on a method or class declaration, Up and Down will move the entire method or class declaration up and down. If you put the text caret in the parameter list of a method, Left and Right will rearrange individual parameters (and then Alt+Enter can invoke the Change Signature refactoring).
More details in the help pages.

View Designer Code in Visual Studio 2010

What is a standard way to open the Designer (automatically generated) code for a VB file?
As a workaround, I can get to it by searching the entire solution for some keyword that is usually only found in those files: Global, Partial, etc.
Open the Solution Explorer. Along the toolbar at the top there is a tool Show All Files (it is the 2nd from the left on my version of visual studio). Click on that tool. All of your Form files will now have an arrow beside them. click on that arrow to expand. Look for the code file named FormName.designer.vb. Double-click on it to open.
You have to click the "show all files"-Button. Then you can also see the Designer.vb-files.
Note: For C# and VS 2008, but the same applies to VB in VS 2010.
http://peterkellner.net/2007/12/31/visualstudioshowallfiles/
http://blog.brianhartsock.com/2009/09/14/visual-studio-tip-show-all-file/
Keyboard shortcut for Show All Files
Show All Files is a useful little button in the Visual Studio solution explorer to give us a full view of the directory structure our project files are sitting in. When it is off, we only see the files that are explicitly included in the project, but when it is on, we see everything. This makes it very easy to explicitly opt a file into the project without doing an add -> existing item -> find existing item in directory structure and add to project.
The default when creating a new Visual Basic application in Visual Studio is to not show all files, and unfortunatly there is no setting you can adjust to change that.
Open the code file, and in the top-right corner of the code window is a drop-down containing all methods. Open this and select "InitializeComponent".
A screenshot from a newer version. Visual Studio 2015 and 2017 will look like this.