DEV Community

Demystifying vim

Mike on August 10, 2018

Before I start, just remember, when in doubt just don't close vim and you'll live. Exiting Vim It's easier said than done for some, the...
Collapse
 
pabuisson profile image
Pierre-Adrien Buisson

Hum, r does not redo last undone change. I believe you meant Ctrl-R or :redo (r in normal mode would allow you to replace the char under the cursor with the char you'll type).

Collapse
 
michaelgv profile image
Mike

My mistake, I’ve got my keybindings setup for r as redo!

Collapse
 
delbetu profile image
M Bellucci

good mapping suggestion!

Collapse
 
pcvonz profile image
Paul

If you're in a linux environment, try running the command:

vimtutor

In your terminal. If you're like me you'll become a vim convert

Collapse
 
moopet profile image
Ben Sinclair • Edited

In your example of fixing indentation you're missing the <F7> bit. Use backticks to escape code.

Actually I hate to say it, but this tutorial is wrong in the undo section too. Use u to undo in the general case, not U. Capital U undoes a single line, and basically works in a different way (and it'll not be obvious to new users how it's working).

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

Fix the indentation:

  • gg=G for whole file
  • =G from actual row to end of file
  • == actual line
Collapse
 
rattanakchea profile image
Rattanak Chea

This needs to go to my vim cheatsheet. Is there a part 2? How can I copy and paste a section of text?

Collapse
 
jerpint profile image
jerpint

v Will get you in visual mode. You can highlight the section you want, then yank (copy) with y. To paste, use p. You don't need to visually select to copy/paste. You could yank the word yw, or yank to the end of the line y$ , or yank the entire line yy

Collapse
 
vlasales profile image
Vlastimil Pospichal

V will get you in select mode. It's little diferent from visual mode, but commands are similar.

Thread Thread
 
tbodt profile image
tbodt

V is visual line mode, not select mode. It's the same as visual mode but it's line oriented, so you're cutting or pasting entire lines and not characters.

Collapse
 
thomasjunkos profile image
Thomas Junkツ

And then, there is :x