In some of my C++ files in Visual Studio 2010, there are these strange icons next to the line numbers. I cannot click on them, right click on them, or interact with them in any way. The only thing I can do is move / delete lines of code and these icons follow the line they are on / get deleted when the line is deleted.
I have looked everywhere but have found nothing. Can someone tell me what these are?
Those are bookmarks.
You can remove a bookmark using the menu option Edit -> Bookmarks -> Toggle bookmark or pressing Ctrl+K twice.
You can use Edit -> Bookmarks -> Clear bookmarks or press Ctrl+K, Ctrl+L to remove all bookmarks in the file.
The purpose of the bookmarks is that you can quickly jump between them.
Related
The Show All Files option in Visual Studio's Solution Explorer keeps toggling on for some reason. What shortcut key does it use and how do I disable it?
For some time now I would randomly find the Show All Files option enabled in solution explorer and I couldn't figure out what was causing it. Thanks to Keyboard shortcut for Show All Files I knew the keys but there was no keyboard shortcut bound to the SolutionExplorer.Folders.ShowAllFiles command. What's actually happening is that Alt+P opens the Project menu then pressing O will toggle show all files.
This was happening often to me because I use Visual Assist's Open File in Solution default shortcut Alt+Shift+O and would sometimes hit P on the way accidentally. To remove this shortcut and behavior you actually need to edit your menu items. Open the Customize menu (Tools->Customize) and remove both entries for Show All Files.
I always found myself rolling the mouse wheel when programming for my project in visual studio 2013. I always need to look through my program code like at line 23 and then modify the code at line 220 and keep forth and backward. It get my eyes tired easily. Is there any tricks to help me save some reference points?
In the upper right corner of your code window there is a little arrow type icon which you can drag down to allow viewing of 2 different areas of the same window/tab. Very helpful when you are needing to go up and down in the same window.
Menu Window -> Split
Or as said Yosem above you can use arrow at corner of code window.
UPD. Also you can make a bookmarks for any lines you want. It's in menu Edit -> Bookmarks -> Toggle bookmark (by default shortcut is ctrl+K, ctrl+K or ctrl+F2). Then you can easily go to next/previous bookmark by pressing F2 / shift+F2
Is it any keyboard shortcut or free addon in Visual Studio 2010 that allows to switch between header (C/C++ .h file) and implementation (C/C++ .cpp file)?
MS added this feature in Visual Studio 2013. It's a default keyboard shortcut Ctrl + K, Ctrl + O
To clarify: Keep Ctrl pressed, type K, type O, release Ctrl.
You can find the command this maps to from the customize-keyboard options as well (tested for VS2015):
Visual Studio does not have a built-in keyboard shortcut to switch back and forth. A macro is by far your best bet if you want to automate this with a single keyboard shortcut. For a list of suggested options, see the answers to a previous question.
The add-in Visual Assist X provides this feature with the shortcut Alt+O (however, add-ins are not supported by the Express editions of Visual Studio).
If you're trying to avoid using a macro, there is an alternative way to achieve a similar result, although it is a two-click process:
To switch from header to implementation:
Right-click a.cpp file and choose "Go To Header File" from the context menu.
To switch from implementation to header:
Right-click an identifier declared in the header and choose "Go To Definition" from the context menu.
My workaround to this problem is a bit unorthodox but it might help others, so I'll share.
I use the window list. And I thought it would annoy the heck out of me doing it this way, but I've actually gotten quite used to it. It continues to apply, even in Visual Studio 2012, so I'm offering it as yet another alternative.
Once both the .cpp and .h files are open, I switch between them like this...
To switch from .cpp to .h: Alt+W, W, Down Arrow, Enter
To switch from .h to .cpp: Alt+W, W, Up Arrow, Enter
You can actually hold down the Alt key while pressing the W the second time, effectively making it: Alt+W, Alt+W, Down Arrow, Enter (You don't have to release the Alt key until you type the arrow key)
This works because the .cpp and .h files are typically adjacent alphabetically in the window list. It also works for .c and .h for the same reason. Breaking it down: Alt+W goes to the "Window" menu, and the second W activates the "Windows..." window list viewer. The active window will be selected in the list box, so pressing the up or down arrow key will move to the document that is before or after alphabetically, which is almost always the corresponding .h/.cpp file.
As yet another alternative, I should also mention that if you place the .cpp and .h files beside each other in the window tabs, then you can use: Ctrl+Alt+Page Up, and Ctrl+Alt+Page Down to switch between adjacent tabs in the tabbed window list.
I realize that you have to "prepare" by having both documents open, and this is less than ideal, but I typically have all my documents open anyway, and I use the Alt+W, W shortcut a lot.
Such shortcut key is added in CodeMaid. CodeMaid is an open source Visual Studio extension
Ctrl + M then ,
http://visualstudiogallery.msdn.microsoft.com/76293c4d-8c16-4f4a-aee6-21f83a571496/
In VS2010 - The keyboard shortcut "EditorContextMenu.CodeWindow.GoToHeaderFile" does the same thing as the right click menu. Unfortunately it doesn't work as a toggle to switch back again. (Though, you can use ctrl - to go navigate back if you started in the cpp).
I find myself going to about five or six main places in my code 80% of the time and would like a way to go to them fast even if all files are closed.
I would like to be able to open up a solution in Visual Studio and without any files open, see a list of self-labeled bookmarks like this:
LoadNext
Settings page refresh
app.config connections
app settings
stringhelpers top
stringhelpers bottom
I click one of these and it opens that file and jumps to that position.
How can I best make bookmarks like this in Visual Studio 2008/2010?
Use task list shortcuts:
On a line in text editor use keys (ctrl + k, ctrl + h) this will add a task list shortcut.
Open task list tool window.
In task list tool window select "short cuts" in the drop-down list.
The task list will the show a list of lines where you made a task list shortcut, whit the text from that line.
Why not use the Bookmarks feature? I have the Bookmarks window at the bottom of my Visual Studio window, collapsed. You can view this by going to View -> Other Windows -> Bookmark Window (in VS 2008, anyway).
You can add a bookmark to any line of code; it will then appear in the Bookmarks window. You can then rename the bookmark to whatever you want. It doesn't matter if the file is open or not.
I'm assuming you want this on a per-solution basis rather than a generic set of bookmarks that know how to find a particular type of file. The approach above would seem to be what you want. It seems like Visual Studio remembers a set of bookmarks for each solution; I guess they're stored in the .suo file.
I have a file, xyz.cpp. I want to open two instances of this file in Visual studio (BTW, I am using Visual Studio 2005). Why would I want to do so? I want to compare two sections of the same file side by side. I know workarounds such as:
Make a copy of the file. But the problem is that it's not elegant, and I don't want to make copies every time I am faced with this.
I can split the window into two. The problem with split it that I can split it horizontally only. The result of a horizontal split is that the right half of my screen is white space.
If I were able to split it vertically or open two instances of the same file, it would increase the number of lines of code I can compare.
Visual Studio
Here's how to do it...
Select the tab you want two copies of
Select menu Window → New Window from the menu.
Right click the new tab and select New Vertical Tab Group
If New Window is not listed in the *Window menu note that the command does exist, even as of Visual Studio 2017. Add it to the Window menu using menu Tools → Customize → Commands. At that point decide where to put the New Window command and select Add Command.
VS Code
In Visual Studio Code version 1.25.1 and later
Way 1
You can simply left click on your file in the side-panel (explorer) and press Ctrl + Enter.
Way 2
Simply right click on your file in the Visual Studio Code side-panel (explorer) and select the first option open to the side.
For Visual Basic, HTML and JScript and RDL Expression, the Window > New Window option mentioned in PaulB's answer is disabled.
However an option can be changed in the Registry to enable the menu item.
All other languages do not restrict to a single code window so you can use PaulB's answer without editing the registry.
Enabling New Window in Windows Registry.[1] [2]
Go to the following registry key. This example is for Basic (Visual Basic), but the key is also there for HTML, JScript and RDL Expression.
64-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
32-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
Find the value Single Code Window Only and do one of the following:
Set it to 0
Rename the value
Delete the value (use caution!)
This will enable the "New Window" menu item, but it may still not be visible in the menu.
Adding Menu Item
To actually see the New Window menu item I had to add it back into the menu:
Tools > Customize... > Commands > Add Command...
Select 'Menu Bar' the select the 'Window' menu in the dropdown
Add Command... > Window > New Window > OK
Restoring Registry Value
Copy-paste this to notepad, save as a .reg file and import the file into your registry to restore the initial setting.
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic]
"Single Code Window Only"=dword:00000001
Go to menu → Windows → New Window:
You can use the Windows → New Window option to duplicate the current window. See more at: Why I like Visual Studio 2010? Undock Windows
Open the file (if you are using multiple tab groups, make sure your file is selected).
Menu Window → Split
(alternately, there's this tiny nub just above the editor's vertical scroll bar - grab it and drag down)
This gives you two (horizontal) views of the same file. Beware that any edit-actions will reflect on both views.
Once you are done, grab the splitter and drag it up all the way (or menu Window → Remove Split).
How to open two instances of the same file side by side in Visual Studio 2019:
Open the file.
Click Window → New Window.
A new window should be open with the same file.
Click on Window → New Vertical Document Group.
Result:
With the your file opened, go to command window (menu View → Other Windows → Command window, or just Ctrl + Alt + A)
Type:
Window.NewWindow
And then
Window.NewVerticalTabGroup
worked for me (Visual Studio 2017).
Or using menus:
Menu Window → New Window
Menu Window → New vertical tap group
Luke's answer didn't work for me. The 'New Window' command was already listed in the customize settings, but not showing up in the .js tabs context menu, despite deleting the registry setting.
So I used:
Tools
Customize...
Keyboard...
Scroll down to select Window.NewWindow
And I pressed and assigned the shortcut keys, Ctrl + Shift + W.
That worked for me.
==== EDIT ====
Well, 'worked' was too strong. My keyboard shortcut does indeed open another tab on the same JavaScript file, but rather unhelpfully it does not render the contents; it is just an empty white window! You may have better luck.
Window menu, New Horizontal/Vertical Tab Group there will do, I think.
When working with Visual Studio 2013 and VB.NET I found that you can quite easily customize the menu and add the "New Window" command - there is no need to mess with the registry!
God only knows why Microsoft chose not to include the command for some languages...?
For newer versions (such as Visual Studio 2017)
Select the window you want to duplicate.
Go to the window tab and click on split at the top of the list.
When you are done, click it again to toggle it off.
For file types, where the same file can't be opened in a vertical tab group (for example .vb files) you can
Open 2 different instances of Visual Studio
Open the same file in each instance
Resize the IDE windows & place them side by side to achieve your layout.
If you save to disk in one instance though, you'll have to reload the file when you switch to the other. Also if you make edits in both instances, you'll have to resolve on the second save. Visual Studio prompts you in both cases with various options. You'll simplify your life a bit if you edit in only the one instance.
I don't have a copy of Visual Studio 2005, but this process works on Visual Studio 2008:
Open xyz.cpp along with some other file.
Right click on tab header and select new vertical tab group.
Left click on that other file in the first tab group.
Open xyz.cpp through solution explorer again.
You should now have two instances of file in separate vertical tab groups.
To work on two sections of one long file, simply use a shortcut (Ctrl + \) or click on the split editor window while you are on the selected tab. The icon is on the top-right of the Visual Studio Code.