vs2012 shortcut keys for moving lines of code - keyboard-shortcuts

what are shotcut keys in vs2012 ,which to copy a line of code then move down or up,and cut a line of code then move down or up??
the copy version:
printf("hello world");// press a shotcut key ,then ..
printf("hello world");// this line of code automaticly appear here.
the cut version:
printf("hello you");//press a shotcut key ,then this line **will be cut**,and then ..
printf("hello you");//this line of code automaticly appear here.
is there any shotcut key exists likes them?

Shift-Alt-T moves the line with the cursor down one line, I'm still trying to figure out how to move it up.
So after a little bit of googling it doesn't seem that VS has a keyboard shortcut to move a line up, which is quite baffling since the do have the above mentioned shortcut to move a line down. Anyway, you're definitely not the only one who wants this functionality and there are a few suggestions to this.
Either install this extension (free):
MoveLine extension
Or you could install ReSharper which is really, really nice in my opinion:
ReSharper

You should try this explanation below:
http://www.herrodius.com/blog/52

The Visual Studio Productivity Power Tools extension adds support for this. It's the "Move Line Up/Down Commands" feature.
With this feature enabled Alt+↑ and Alt+↓ move the current line (or multi-line selection) up or down.
Usually the first thing I do when set up visual studio is install this extension, then turn off all the other rubbish it adds (weird document tabs, scrollbar etc) just for the move up and down

Related

Atom: Imitate 'Shift-Enter' keybinding of IntelliJ

In IntelliJ IDEA, one of the more helpful commands I've found is 'Shift-Enter' - it effectively moves the cursor to the end of the line, and starts a new line, thus not affecting the text on the current line.
I'd like to re-create this in Atom, but I can't seem to figure out how one would go about doing so. It doesn't look like you can have multiple editor actions for a given key combination, and I'm not sure if I simply can't find the esoteric editor command I'm looking for.
How can I recreate the behavior of shift-enter in IntelliJ for Atom?
As it so happens, I stumbled across the shortcut: You can use cmd-enter to do the same action. I'm not sure what the underlying command is, but I hope this is helpful to other people!
You can recreate this behaviour by adding this to your keymap:
'atom-workspace atom-text-editor:not([mini])':
'shift-enter': 'editor:newline-below'
Detailed answer;
Freshly open atom editor
Open Keymap option
Copy this and paste this;
'atom-workspace atom-text-editor:not([mini])':
'shift-enter': 'editor:newline-below'
Click save and close the file
Press Shift and enter, Now you'll be able to form a new line below the line you currently in are regardless of the place you are typing in.

Undo, Redo is jumping around and unpredictable (Test on PHPStorm)

I'm using PHPStrom v 8.0.2
While i was hit command-Z to undo thing.
The editor jump around to somewhere but not to the cursor as illustrated image.
That makes me very annoyed.
Is this a bug or have i setting something wrong?
HERE IS HOW TO REPRODUCE
Edit any line
Place the cursor far... far away from the edit line
Hit command-Z to UNDO thing <-- The editor will jump to the edited line
Hit command-shift-Z to REDO thing, the editor jump back to the line in (2) <--- NO... IT SHOULD NOT
Seem like Jetbrains does fix this in PHPStorm v9 EAP.
But that program will expired after 30 days, Any where to implement this in PHPStorm v8.0.3 please?
One more thing, I can't find any keyboard shortcut key for auto indent for the whole document, please advise.
Best Regards,
This seems to be Intellij default behavior; it treats cursor movements as edit actions and as such they are being undone and redone.
See this post

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.

aptana studio delete line

I'm testing out Aptana Studio to do some javascript development I want to know if there is a shortcut to delete a whole line. Or if there is a way to create some kind of macro to do it.
I am running windows, and I know that I can click Ctrl+Shift+Del but that doesn't actually do what I want it to do. In VS when you click Shift+Del it doesn't matter where the cursor is on the line it will delete the whole line.
To do the same in Aptana I need to:
Click Home to get me to the beginning of the line
Click Ctrl+Shift+Del to delete the content of the line
Click Ctrl+Shift+Del to delete the line
This may seem small, but I do this action all the time in VS and I've grown accustomed to it.
Anyone have any ideas to help me out?
I just figured it out:
It's quite simple: Ctrl+D
Also if you want to change the key binding you can
Go to menu Window -> Preferences
Go to General -> Keys
Find Command 'Delete Line' and then bind it to your desired key combo(like Shift+Delete)

Keyboard shortcut to Un/Comment out code in Mathematica 7?

A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working.
I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and select Un/Comment from the menu that appears but this is too slow while coding.
I tried to access this using the menu key Menu on the keyboard but Mathematica frontend doesn't respond to or recognise this key unlike other applications, this could have allowed a key combination for commenting. Can someone else verify that this isn't unique to my machine and that the key isn't recognised by mathematica. I looked at this question and looked in the KeyEventTranslations.tr file but I don't think there is any way to create a shortcut to do this(?). Should I just live with it?
Any other suggestions?
(I have seen there is an Emacs version of mathematica, I have never tried Emacs or this Mma version and imagine that it would have this ability but would prefer not to go to the trouble and uncertainty of installing it. Also I would guess that the Wolfram Workbench could do this, but that may not be worth the investment just for this.)
You can install the shortcut in Mathematica 7.0.x if you are willing to edit the Mathematica system file MenuSetup.tr. You can find it in the same location as the KeyEventTranslations.tr file (i.e. in the installation under "SystemFiles/FrontEnd/TextResources/platform"). In MenuSetup.tr, locate the following line under the definition of the Edit menu:
MenuItem["Check &Balance", "Balance", MenuKey["B", Modifiers->{"Control", "Shift"}]],
Immediately below that line, insert the following:
MenuItem["Un/C&omment Selection", KernelExecute[FE`toggleComment[]], MenuKey["/", Modifiers->{"Command"}], MenuEvaluator -> Automatic, Method -> "Queued"],
The Un/Comment Selection command is now available under the Edit menu, with the keyboard shortcut Cmd-/ or Alt-/ depending on your platform -- just like in Mathematica 8 where this command comes pre-installed.
Please take as read the usual disclaimers about hacking the Mathematica installation files -- no warranty is offered :)
I do not know of any way to map this function to some shortcut involving the Menu key.
Shortcut Key, No Menu
The preceding steps mimic what Mathematica 8 does by installing a new menu item. If you prefer to leave the menus unchanged, then you can install the shortcut in KeyEventTranslations.tr instead. Add the following line:
Item[KeyEvent["/", Modifiers->{Command}], KernelExecute[ToExpression["FE`toggleComment[]"]], MenuEvaluator -> Automatic, Method -> "Queued"]
You'll need a comma on the end of that line if it is not the last item in the list.
Select the code and press one of the following:
Alt+/
Alt-E-O
Alt+E+O
Notes:
Tested only on Windows, using Mathematica 8.
On my non-US keyboard (ABNT Brazil), the shortcut Alt+/ doesn't work, instead I use Alt+E+O.
Here is code for your KeyEventTranslations.tr file that will comment out code. I am still working on the other half.
Item[KeyEvent["/", Modifiers -> {Command}],
FrontEndExecute[{
NotebookApply[FrontEnd`InputNotebook[],
"(*\[SelectionPlaceholder]*)"
]
}]
],
This binds it to Alt+/ as it is in Mathematica 8.