Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Moving the cursor to another position in code is one of the most frequent actions when coding. I don't write my programs from the beginning to the end, like a letter. However, moving the cursor requires me to move my right hand to the key arrows or to the mouse, which feels like an interruption to my writing rhythm, since I'm using touch typing. I want my hands to rest on the keyboard. It's difficult to explain what I mean, but I think every coder using touch typing knows what I mean.

I tried many things, like defining some shortcuts as surrogate arrow keys (Shift+Alt+J, K, L, I), or buying a keyboard with a Trackpoint, Trackpad, or Trackball on it, but I have not yet found a satisfying solution to the problem.

What is the best solution you know of, regardless of which IDE you use?

Edit:

Thank you for your answers. I am using a lot of shortkeys, but I think using a Vim plugin in Visual Studio would interfere too much with the shortkeys I am used to. Also, I have a keyboard with a built-in mouse, but I'm still looking for a better solution.

share|improve this question
    
I wonder if you would find the following useful: http://weblogs.asp.net/scottgu/archive/2010/07/29/visual-studio-2010-keyboard-s‌​hortcuts.aspx –  Kyle Hodgson Dec 12 '11 at 18:18
    
Unless I missed it, the VB version has the "Previous Word and Next Word" CTRL LEFT ARROW and CTRL RIGHT ARROW, but the C# version doesn't have it, under the Navigation section. –  Bratch Dec 12 '11 at 21:44
    
@Bratch I never read the manual, but those hotkeys definitely work in C# mode. –  Wyatt Barnett Dec 12 '11 at 23:30
    
Yeah they work in almost every Window application. My vote went to Thomas Owens' answer for the hot keys, along with Oded's comment aboout the Ctrl + arrows. I also use these in combination with a shift key when selecting text. –  Bratch Dec 13 '11 at 2:01
    
Shortcuts are not enough, there is a limit of what you can do with the default Visual Studio editor. Unless you're going to implement a half of Emacs of Vim as a VSIX extension, you'll be much better off just using Emacs of Vim instead of MSVS. Their navigation capabilities are great (but very different: emacs approach is to use long C-something commands, and vi is a two-mode editor). –  SK-logic Dec 14 '11 at 12:15
add comment

7 Answers 7

maybe you cold try VIemu link

VIemu

this way you can continue to use VS itself and only use vi key bindings which you need like for just navigation improvement though there's no need to know all of vi's commands knowledge of these is sufficient press esc and then:

Vim Line Navigation

Following are the four navigation that can be done line by line.

k – move upwards
j – move downwards
l – move right side
h – move left side

By using the repeat factor in VI we can do this operation for N times. For example, when you want to go down by 10 lines, then type “10j”.

Within a line if you want to navigate to different position, you have 4 other options.

^ – go to the first non blank character of the line.
$ – go to the end of the current line.

NG to move to line N

after navigating to the desired location press i to place the cursor to the previous location or press a to place it to the next location.

and word navigation in VS is simple enough with ctrl+[arrow keys]

and for complete navigation use sites like this one

vi navigation is great as long as you use a qwerty layout and if you want to use more vi actions like replace,delete and copy commands try vimtutor for a basic introduction (it comes with gvim link)

share|improve this answer
    
Did you use this one? Can you recommend it? Looks like one of the projects where my answer fell short. –  sebastiangeiger Dec 12 '11 at 18:49
    
@sebastiangeiger no i haven't as iv'e switched to Linux but others who use it seem to recommend it like here link –  Siamore Dec 12 '11 at 19:09
1  
vi is nice..... –  user1249 Jun 21 '12 at 10:43
add comment

Keyboard shortcuts are your friend here. For example, Home and End keys to jump to the start or end of a particular line, CTRL+Home and CTRL+End to jump to the top or bottom of a file, and Page Up and Page Down to scroll through a file. In the comments, Oded also mentions Ctrl+{arrow key} to jump from token to token. There are a number of standard text navigation shortcuts that I would suspect that most IDEs support, in addition to these examples.

Kyle Hodgson's answer provides a list of keyboard shortcuts for Visual Studio 2010 and you can also find a list of Eclipse and NetBeans keyboard shortcuts, plus most IDEs allow you to create new shortcuts and modify the existing ones as you see fit.

share|improve this answer
5  
No to mention Ctrl + arrow keys to jump from token to token. –  Oded Dec 12 '11 at 18:21
    
@Oded That's another one. There are a bunch of standard keyboard shortcuts that I didn't see mentioned in the lists that Kyle linked to that that are helpful for navigating not only Visual Studio, but most other IDEs as well as word processors. –  Thomas Owens Dec 12 '11 at 18:22
1  
Agreed - knowing how to keyboard your way around windows/controls/text is useful beyond Visual Studio. –  Oded Dec 12 '11 at 18:23
    
I know vim does not really fulfill the Visual Studio requirement, yet PageUp and PageDown on a regular keyboard are really conflicting with the touch typing part. –  sebastiangeiger Dec 12 '11 at 18:51
    
@sebastiangeiger How so? It's easier and faster to move your right hand to Home/End/Page Up/Page Down and have access to the Shift and Control modifiers (or from that position back to a typing position) than it is to move your hand to the mouse. –  Thomas Owens Dec 12 '11 at 18:54
show 1 more comment

At the risk of sounding like a fanboi, the canonical editor for touch typists is vim. The tradeoff is a loss of integration. If editing speed is more important to you, then it is well worth the learning curve.

share|improve this answer
    
Many IDEs already have their own keyboard shortcuts and let you define new ones or change existing ones. If you aren't a vim user, learning the capabilities of your IDE might be easier than trying to force another tool's paradigm. If you use multiple IDEs, the trade-off becomes either learning each IDE's shortcuts or spending the time to try to mimic one set of shortcuts in other IDEs. –  Thomas Owens Dec 12 '11 at 18:43
    
actually the canonical editor for touch typists is emacs :-) –  Jarrod Roberson Jun 21 '12 at 14:49
add comment

The argument that people are making in favor of vim sounds a lot like the one you mentioned. Most of the time you are navigation through text, trying to get to the site where you actually want to edit text. Text navigation is where vim excels.

Unfortunately vim is a standalone editor and you probably don't want to abandon Visual Studio just for nicer text navigation. However there are projects that are trying to emulate vim's behavior inside Visual Studio. Sadly I cannot recommend any of them since I don't use Visual Studio.

A word of warning: I used Vrapper for Eclipse in the past and while it promises vim behavior it just doesn't feel right, so maybe my answer is completely worthless ;-)

share|improve this answer
    
These plugins are trying to introduce vim-like shortcuts into editors. Many IDEs already have their own keyboard shortcuts and let you define new ones or change existing ones. If you aren't a vim user, learning the capabilities of your IDE might be easier than trying to force another tool's paradigm. –  Thomas Owens Dec 12 '11 at 18:41
    
@ThomasOwens See my word of warning. I am a vim user and the eclipse plugin didn't even work for me. However, my real reason to respond is to stress the difference between a mode based editor and simply introducing "shortcuts". You will still be using the Visual Studio shortcuts most of the time. The vim plugin should ideally only help you with navigating the text. –  sebastiangeiger Dec 12 '11 at 18:46
    
I don't like vim, so I haven't tried the NetBeans and Eclipse plugins, but in both Eclipse and Visual Studio (prior to 2010, but I suspect they haven't changed that much in terms of keyboard shortcuts in the latest VS), I have no problems navigating and manipulating the text by only using the predefined keyboard shortcuts. However, I've found that the people who tend to look at these vim-behavior-adding plugins are former vim users who are now using IDEs, and not people who are unfamiliar with vim who want to get better at using only the keyboard to navigate their IDE. –  Thomas Owens Dec 12 '11 at 18:49
    
Agreed. But, what about former IDE users that where forced into vim and now actually like it? :-) –  sebastiangeiger Dec 12 '11 at 18:53
    
I couldn't speak to that. No one should be forced into using any particular tool. With the exception of rare times when I'm doing .NET development, I do everything else in Eclipse. –  Thomas Owens Dec 12 '11 at 18:57
add comment

I don't type enough at one time for it to matter.

I only type for a small fraction of the time I am on the computer. Most of the time is spent looking through code with the mouse for the right spot to put the line of code that's required.

Even in new development I find I spend more time switching between files, than remaining in a single file.

I'll modify the screen on the UI, then modify it's js, css, and xslt files. Then drop into the data layer, modify a class. Drop into the db, modify a proc and table.

And in the end, I've probably modified 10 files to add a new feature. However, in each file, I only modified a line or two.

And most of the files don't span more than a page or two at most, so navigating is trivial whether with the keyboard or mouse.

Seems to me like you need to split your code up more rather than improving your ability to navigate around large files.

And when I do move around in a file, I can go to the arrows, and back to home row without thinking about it. I've done it several times while writing and editing this post in fact. I don't look at the keyboard, the arrows are in a known location that's rather easy to find. And moving around with the ctrl-arrow combinations makes it rather fast.

share|improve this answer
add comment
up vote 1 down vote accepted

I found the answer to this question in this product:

http://ergo.contour-design.com/products/rollermouse-free2

Of course, keyboard shortcuts and great editors/IDEs are very important, but I specifically asked for a solution which works

regardless of which IDE you use

I'm not affiliated with the manufacturer.

share|improve this answer
add comment

You can always get a keyboard with a mouse integrated; I prefer the ThinkPad style trackpoints myself such as this one.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.