jEdit supports block editing, but Emacs and Vim seem to have some serious usability issues on the same subject. If someone could fill in the unknowns here it would be much more bearable to use either editor:

  • Actual rectangular selection: Where the selection on screen is a rectangle, not a linear selection which is then used to calculate a region as Emacs seems limited to.
    • jEdit: Hold down Ctrl and select.
    • Vim: Click Ctrl-v and select.
    • Emacs: Unknown; looks like a 400+ lines plugin is necessary.
  • Live rectangular editing: See what the result will look like on all lines as you edit after a block selection.
    • jEdit: Just start typing, and you'll see the end result as you go.
    • Vim: Click Shift-i and type. Will show the end result only on the first line until you press Esc to exit insert mode. Unknown whether there is some way to see the result on all lines immediately.
    • Emacs: Unknown; looks like the only way is C-x r t and setting the text to fill in after pressing Ret.
  • Start and end selection in positions outside the text: For example, I'd like to remove the N first characters of each line, but the first and last lines contain less than N characters.
  • Paste block inline: Paste the copied block as if you were pasting multiple lines, as in, push the text already there down, not right.
    • jEdit: The default. To paste a block as a block you need to do another block selection first.
    • Vim: OEscVp.
    • Emacs: Unknown.

General Emacs block selection functionality can be found in the cua-mode plugin.

  • Apparently Emacs' column editing mode can do some kind of live rectangle editing: youtube.com/watch?v=k-6BVjlBSVo
    – Tom
    Commented Oct 14, 2011 at 16:18
  • Just a observation about emacs 400+ lines "plugin".. A somewhat similar addon for gedit, called multi-edit has 1000+ lines of python code. For me, the pugin is so useful (how did I survive without it), the size is academic... and if the emacs one works as advertized, I'd be more than happy to use it, but I got a load error when I ran it "command-line-normalize-file-name: Args out of range: "", 1" :( ... It's just what I've been looking for too..
    – Peter.O
    Commented Oct 14, 2011 at 18:26
  • 4
    For those who haven't used jEdit, please explain your terminology. I don't understand what “live” means here, what “live rectangular editing” is, or what “paste block inline” means. Commented Oct 14, 2011 at 22:57

4 Answers 4


I can answer for Vim, but not Emacs.

Start and end selection in positions outside the text:

:set virtualedit=block will enable the behavior you want. You can drop the initial colon and add it to your .vimrc if you like. For more info, :help 'virtualedit' from within Vim.

Paste block inline:

If you just hit p in Command mode, Vim will insert the block, pushing characters to the right on each line. If you select another block and hit p, Vim will replace that block with the pasted block.

You can paste a block "linewise" with the command-mode key sequence OEscVp. This inserts a line above the current line (O Esc), selects it linewise (V), then pastes over it (p). You could shorten this to (for example) yp with a mapping such as :nmap yp O<Esc>Vp -- type that literally; use five keystrokes for <Esc> rather than pressing the Escape key.

  • Nice tip about virtualedit; have to try that out. About inline pasting, please see the updated question for a description of the expected functionality.
    – l0b0
    Commented Oct 15, 2011 at 20:55
  • I've updated my answer with a method to paste blocks linewise.
    – Jander
    Commented Oct 16, 2011 at 5:11

For example, I'd like to remove the N first characters of each line, but the first and last lines contain less than N characters.

Emacs: start selection at the first line and simply add the missing number of characters (e.g. spaces) to the last line and then use kill-rectangle

Alternatively, see artist-mode or picture-mode which allow you to freely move in the window regardless of line lengths.

Paste block inline

Emacs: First save the block by either kill-rectangle or saving it to a register, then go to the insertion point, use delete-rectangle and then insert the saved rectangle.

looks like a 400+ lines plugin is necessary

In case of Emacs why is it a problem? A plugin can be compiled and the emacs philosophy is you don't put everything into the core, but use plugins to extend the editor.


There is 'cua-mode' which comes with Emacsen 22.1 and later, or follow the link to download for earlier versions of Emacs. There's a short video that introduces the functionality.

For general rectangle commands, try reading the manual, which provides an easy introduction.

  • emacs cua-mode looks good! +1.. I couldn't find the video you mentioned, see Tom's link in the comments immediately below the question, for a link to a (different?) info video...
    – Peter.O
    Commented Oct 15, 2011 at 7:01
  • @fered Ooops, cut/paste error, fixed. Commented Oct 15, 2011 at 14:31

In vim, the typical way to delete the first n characters is to do something like :%s/.\{0,6\}//.

% will do the whole document; you can replace that with a selection or with the actual lines you care about. The s command is for "substitute". It will replace a regular expression with whatever you give it, and it will only match once on each line unless you add a specific option. The / is a delimiter - this can be any character, but / is usually used unless it is advantageous to use something else (so you don't have to escape / in the rest of the command). The argument after the first delimiter is a regular expression that will be used to find matching strings in your selection. The argument after the second delimiter is what the match will be replaced with.

So this command says find 0 to 6 instances of any character, and replace them with nothing.

  • Not what I asked for.
    – l0b0
    Commented Oct 15, 2011 at 20:51
  • But do you think it's not useful for others who find this question? I think it is, and that's why I put it here. Commented Oct 16, 2011 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .