Skip to content
Jason Charney edited this page Jan 19, 2015 · 4 revisions

Vim is the must know text editor for Linux and usable for any other operating system because it is open source software.

While everyone is entitled to their opinion on which text editor you should use (be it emacs, nano, gedit, etc.), Vim is how we role with Rigel.

Copypasta like a boss

Here's what you need to know about a few vim commands:

  • mX means set a mark with a mark X. X can be any letter a through z.
  • d is the start of a "delete" command, but in Vim, it really means CUT rather than delete.
  • y is the start of a "yank" command, or COPY.
  • p and P are the "put" commands, or PASTE.

The useage of d and y commands are complex, but for simplcity, well just explain cutting or copying from a mark to the current line. Assuming you've set a mark, you can scroll to the other line that you want to set as the place to cut or copy from. It can be above or below the line you marked, it really doesn't matter. If will matter if you use number in your cut/copy command, so we won't mess with that.

A good way to keep thing straight is to use the buffer d for when you delete (cut) a set of lines, and y for when you yank (copy) a set of lines. Thus.

  • d'd means "delete the lines from here (the current line) to where mark d is marked"
  • y'y means "yank the lines from here to where mark y is marked."

This here is the process for deleting (cutting) a set of lines and pasting them elsewhere.

  1. md (mark the current line with the mark d.)
  2. Scroll up or down to the other line you wish to use as a boundary.
  3. d'd delete the lines from d to here. The lines between where d was marked and the line that the cursor was currently one should be removed.

Now let's see how yanking (copying) works. This here is the process for deleting (cutting) a set of lines and pasting them elsewhere.

  1. my (mark the current line with the mark y.)
  2. Scroll up or down to the other line you wish to use as a boundary.
  3. y'y delete the lines from y to here. The lines between where y was marked and the line that the cursor is is still there.

Note that these two methods DO NOT store our lines to a named buffer. Marks and buffers are not the same.

Finally the putting (pasting) part.

  • Use p to put the cut or copied lines on the next line.
  • Use P to put the cut or copied on the current line.

For more information see

See Also

External Links

Clone this wiki locally