Visual studio Reformat Code/Document - visual-studio

I can't find the Reformat button, I know I can use ctrl+k+d, but I wish to have also the toolbar with the button. can someone help me ?

You can use Edit > Advanced > Format Document and you can also move this as a button to any toolbar. Go to Tools > Customize > Commands, select Toolbar and push Add Command button. Then select Edit category and find Document Format.

Apparently VS2010 (maybe others) hide certain commands depending on the style you choose. I chose Web Dev (code) as my choice and the Document Format is not present to be added to a toolbar. But, if I change to C# Code (tools>Import/Export) then the Document Format command is right there in the Edit menu where others here have said it is.
I had to import the C# Dev layout, but unchecked colors and code formatting options (so it won't overwrite those). What section you must import to get the format document button, I don't know, I didn't experiment that deep.
Seems stupid MS chose to force us down specific paths for layout with no convenient way to get out of it.

If you can't find it in the Edit menu: you can also find it if you press CTRL + P and then type >format. The shortcut is SHIFT + ALT + F

Related

SSIS keyboard shortcuts for packages layout

I am making a few edits on huge DTSX packages in Visual Studio (SSIS), and my target is to make a more tidy layout of the flows.
For this reason, I use to select part of the flows and then use the following menu:
Format > Auto Layout > Diagram
Format > Align > Center
Format > Make Same Size > Both
Format > Horizontal Spacing > Make Equal
Format > Vertical Spacing > Make Equal
Is there a key shortcut for these commands?
I looked over Google and the official Microsoft documentation, but I didn't find anything helpful in this direction.
By default, there are no default keyboard shortcuts assigned for the layout commands:
You can assign your own shortcuts!
In the top menu strip, go to Tools > Options.
Once the options dialog is shown, click on the keyboard section. And select the command you are looking to assign the shortcuts. In the "Show commands containing", type Format. to find the commands related to formatting, e.g. Format.Diagram, Format.MakeHorizontalSpacingEqual, etc. Then press the shortcut you want and click on the assign button (as shown below).
After assigning the shortcuts, you check the command you selected in the menu strip and note that the keyboard shortcut is shown beside it.

How to indent my code in codeblocks?

What are the best code blocks short cuts ? Also is there some way we can directly indent all our code ? In addition how can we move through the active tabs in codeblocks ?
Tips about tab identation are helpful when you write your code from begining. But if you paste code in CodeBlocks from some external source, like PDF document, that code often will not have good identation.
In this case, you need to select code, right click on it, and choose Format use AStyle option.
This is a plugin for CodeBlocks for right text formatting.
I hope this will help someone!
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.
So for indenting a whole file: Ctrl + A, then Tab.
In addition, you can use Shift + Tab on a selected block to "unindent"
You can move through the open tabs with Ctrl + Shift + Tab.
As for the best shortcuts:
I like Ctrl + D to duplicate a line and
Ctrl + L to copy it.
Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).
]2
Add shortcut as you wish from Settings->Editor->Keyboard shortcuts->plugins->Source code formatters(Astyle) or use Plugins->Source code formatters(Astyle)
CTRL+A to select the code and TAB for alignment.
I have not had much luck with the code formatter in C::B. I like my code to look like this...
if (blah..) {
SomeCode();
} else {
DifferentCode();
}
it allows more code to fit on a screen, and is still reasonably readable.
After trying to tweak the settings in Settings->Editor, then Source Formatter tab, when I went to format my code, it removed the if line entirely, and I have not been able to unset my tweaks to make it work.
Fornatually, ctrl-z still works.
The code formatter should never remove code, only play with white space.
Maybe there is a better plugin.
Mark.
In addition in How to switch between tabs in codeblocks.
codebocks 20.03
Linux (KDE Neon)
To switch between tabs.
Activate this with CTRL+SHIFT+TAB, then you can use the know options:
CTRL+TAB , to switch to the right tab.
CTRL+SHIFT+TAB , to switch to the left tab.
Or this other option, but this is not in the keyboard shortcuts, this option doesn't work in a cycle mode, when your get the last right tab, it jump to the bottom tabs:
CTRL+ right-arrow-key , to switch to the right tab.
CTRL+ left-arrow-key , to switch to the left tab.
Remember to activate with CTRL+SHIFT+TAB.
After you land in the desire tab you can type TAB to begin to start writing code.

Xcode4, I use to be able to select some text and right click and search on that text in xcode3?

In Xcode 3 I use to be able to select some text, right click and search for that text.
However in Xcode 4 this seems to have disappeared ?
Is there a quick alternative instead ?
EDIT
I'd select some source code and it would find all occurences in the rest of the source code.
Select text; cmd-E
Then Shift-cmd-F; return
Boom.
Select your text, hit command-E ("use selection for find") and command-G to iterate through results.
Find in Workspace appears to be fundamentally broken in Xcode 4.
Someone else posted a workaround: toggle the Assistant Editor button to enable the menu item. However it still is not available for text in the debug output area.
Search in workspace (you can read the keyboard abbreviation in Edit -> Find -> find in workspace
You can always try some keyboard shortcuts combination once your text is selected:
command+C
command+F (if you want to
search in the current file, otherwise
shift+command+F to look into the
whole project)
command+V
Then you can iterate through the results with command+G to go forward or shift+command+G to go backward.
Hope this helps.

Bookmarks in Visual Studio editor

I'm looking for a plugin/addin for Visual Studio in order to bookmark a line of code.
For example bookmark line xx in file yy with mark "(1)" with keyboard shortcut alt+1 and then just pressing ctrl+1 in order to move to the line (1).
Is there anything like this?
Thanks!
Built-in:
CTRL+K, CTRL+K Create a bookmark
CTRL+K, CTRL+N Next Bookmark
CTRL+K, CTRL+P Previous Bookmark
A better solution to standard bookmarks...
Go to Tools/Options/Environment/Task List and add a new tag to record them. I wanted to use the phrase MARK but this word is too common in my code, so I'm using BOOKMARK set as low priority.
Whenever I want to leave a bookmark I just type //BOOKMARK: this is a bookmark, and that's it, simple!
To view them just open the Task List window and sort by priority or description and scroll down.
This is hugely better than standard bookmarks because they ...
are 'pinned' with the actual code and don't drift
can be shared with your own multiple environments and with other developers
are never lost if you suffer a problem with Visual Studio
are still searchable and readable in other editors eg notepad
you could create different tags to group different types of bookmarks together

Textmate tab and de-tab selected block

Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented.
On Textmate however when I try this it just replaces my selected text with a tab. So is there a way to do tab and de-tab lines of code in textmate?
Indent: Alt+Tab
Un-Indent: Shift+Alt+Tab
the hotkey is command-left bracket to move left and command-right bracket to move right
(the buttons next to 'p')
heres a link to more hotkeys and such
http://projects.serenity.de/textmate/tutorials/basics/
You can use Shift+Tab to decrease indent; You just need to make and assign a macro. You can reuse this technique to accomplish a great many things.
Enter some text, and intend them, this is mostly for feedback.
Click the Record Macro Button
Use ⇧+⌥+⇥ (aka; Shift + Option + Tab) to decrease the indentation.
Click the record button to stop recording the macro.
Use the Edit menu or ⌃+⌘+M to save your macro;
Saving will prompt you to create a new bundle*, or add your macro to an existing bundle.
Add a Key Equivalent by clicking in the field and pressing ⇧+⇥
Your bundle-macro should look like the one below, simply Save and you're done! TextMate will now decrease indent on ⇧+⇥
*: (as noted by u/PatrickT) Sadly the create new bundle functionality has not yet been implemented, and you must choose to add to an existing bundle. You can still create a bundle via Bundles -> Edit Bundles then Command + N.
As an alternative, you can change the keybindings, see Link
Here is what I did:
Install Link
Go to File -> Open -> User Key Bindings, this will create/edit ~/Libary/KeyBindings/DefaultKeyBinding.dict
Add a binding, for the action enter shiftRight: (indent) manually (this is a TextMate specific action and not in the pre-populated actions list)
Choose a shortcut, I used cmd+alt+right
Do the same for the action shiftLeft: (un-indent, I used cmd+alt+left)
Save and then restart TextMate
I used a shortcut with arrow keys as my right hand is already on the arrow keys when I am selecting multiple lines, so this is a good fit.
The reason why I did it was because I have a german keyboard and alt+tab/alt+shift+tab don't work for me since I am using Witch for app-switching using these exact shortcuts.
EDIT: cmd+alt+left/right don't work when you have multiple tabs open, as they are used for navigate to next or previous tab in TextMate... seems this cannot be changed or overridden (I tried Setting Shortcut Keys in Textmate). Looking for an alternative shortcut now.

Resources