Home » Questions » Computers [ Ask a new question ]

Using vim in a high latency environment

Using vim in a high latency environment

I've used vim for years and feel fairly proficient with it. However, recently, I've been working on a server with a 520ms ping time (Sydney to South Africa). This greatly increases my need to use vim more effectively. What can I do to help learn the shortcuts which thus far I've never learned?

Asked by: Guest | Views: 289
Total answers/comments: 2
Guest [Entry]

"To use vim more effectively, I would concentrate on learning more of the specialized movement commands (parens to move by sentence, braces to move by paragraphs). They can be combined with the editing commands (delete, change, etc.) once you are familiar with them. Also, learn the ‘a’ and ‘i’ combinations for selecting (and applying commands to) objects around the cursor (e.g. das to delete the sentence that the cursor is in: compare to (d), which has three Shift toggles). Learn to apply counts for larger movements (e.g. c2w to change the next two words, d2as to delete the sentence the cursor is in and the next one). Use marks to jump to frequently used spots.

I forgot one of my favorite movement commands: f/t/F/T move forward or backwards (lowercase or uppercase, respectively) to the next or just before the next (f or t, respectively) character you type: f* moves to to the next * to the right, T( moves just to the right of the next open parenthesis to the left (swap left and right for right-to-left configurations).

Making big changes

For repetitive edits, use the macro recording function q to record and @ to playback sequences of the same commands.

Use registers instead of copy and paste, it will save a round-trip (since macros are stored in registers, you can use the register store/retrieve commands to fixup errors in the macro without re-recording).

Use the :%s/…/…/g command to make global replacements/deletions.

And if you still can not get it to feel comfortable, you might be able to make edits via the netrw plugin: vim scp://target/somefile.

As akira notes below, this lets you run Vim on your local machine where latency is not a problem. When you edit a remote file, Vim copies it to your local machine. When you save, Vim copies it back to the remote machine. It supports many protocols (WebDAV, HTTP (read-only), FTP, SSH (scp, sftp), rsync)."
Guest [Entry]

"as others already wrote, vim was designed specifically with slow connections in mind, so you just need to learn to use it more effectively.
you need to learn ( and know the difference between) a/A, f/t F/T, i/I, ^, $, o/O, p/P, d/D etc. they are all important and can save you quite a lot of movements.

But the biggest problem from my experience is psychological. you known that eventually it will be faster, but right now its faster (and more importantly easier on the brain :) just to use the cursor keys :).

What I did to learn effective vim is to ""punish myself"" every time I catch myself doing something inefficiently, by going back and re-doing it the right way anyway.

so for example if you just ""caught"" yourself moving 10 lines down with the cursor keys go back and then use smth like ""10"". or more importantly almost never using the horizontal arrow keys, use T,t,F,f,/,? instead. and ""punish"" yourself by redoing it again. you will start to do the right thing in no time.

oh, and another thing to watch is the visual selection mode. 99% its not needed as the same can be done differently."