Is there a shortcut to move the cursor as shown in

2019-06-26 07:07发布

I am using a notebook without a mouse.

After typing prop and pressing tab, Visual Studio will automatically give me a property template. Pressing tab will move the cursor between type and propertyname placeholders.

I want to move the cursor to a new line after completing the property template.

Is there a shortcut to do so?

enter image description here

3条回答
贼婆χ
2楼-- · 2019-06-26 07:40

Press the Enter key twice.

I tried to post this answer 3 times before I left the comment. It wouldn't let me, too short. That's why I'm typing this otherwise useless verbiage.

查看更多
forever°为你锁心
3楼-- · 2019-06-26 07:49

It's not specific to snippets, but you can press Ctrl+Shift+Enter to start a new line below where the cursor currently is.

To insert a new line above where the cursor currently is, use Ctrl+Enter.

Both of these work anywhere in the editor. Both of these are handy because they work no matter where you are horizontally on your current line.

查看更多
Bombasti
4楼-- · 2019-06-26 07:55

Update: Productivity PowerTools for VS2010 (Woot! 2012 too) provides the keyboard shortcut Tools.AddEndTokenAtEnd. (Thanks Ben.)

For some reason, magically, my VS2010 does this with Shift-Enter (which I prefer from my experience with TextMate.) Looking at my keyboard bindings (Tools > Customize > Keyboard) I see that this shortcut is assigned to the command Tools.AddEndTokenAtTheEnd. So if that command appears in your list of commands, assigning a keyboard shortcut to it should work. I have Productivity Power Tools, PowerCommands for Visual Studio 2010, and ReSharper installed. But I can't find any setting from the first two that would be responsible, and, in my experience, all of ReSharper's commands contain its name, so I don't think it added the command. Ooo, and I just discovered that the reason it is named that is because the command also ensures there's a semicolon at the end of the initial line before moving the cursor down; just like the useful keyboard shortcut in Textmate.

I'm interested, but baffled by the 2x-Enter solution. When I press enter twice I get two line breaks followed by whatever code was after the cursor on the first line. Can anyone explain how that shortcut/key-combination works? Is it time-sensitive so that the two enters must be pressed in rapid succession? What if the user wants to quickly insert some lines above some code and hits Return multiple times!?

查看更多
登录 后发表回答