On my gvim screen, there are two sections on a same column:
and I'd like to have two different columns aligned on same lines, like this:
Yes, I think I have read all of the related docs available on the net, but they can't help. So I'm going to rely on the old friends here. TIA.
Visual block select (control-v) and yank the second block. Enter two spaces after the c. Either enter normal mode and paste, or control-o and p.
We only get the [p] result as:
That is, and has been, our current perpetual problem.
You did something wrong.
Well, you have...
In exit mode (escape), move the cursor to 'c'.
Type 'a' to enter insert mode, then type 2 spaces.
Escape again, then move the cursor to 'r'.
ctrl-v to enter visual block mode.
Then type 'l', 'l', 'j', 'j', to cover the block to move.
The current cursor will then move to 'z'.
Type 'd' to delete them.
Then repeating 'k' until the cursor points 'a'.
Then type '$', and finally 'p'.
Hope that helps.
With cursor on the 'r' of 'rst', do this key sequence:
<ctrl-v>lll jj d gg A <space><space><esc>>p
This is same as what Jan said, just putting down the keystrokes.
Thanks Aswin and Pongthep. I think I was doing the same thing as suggested by using the gvim gui, that is, using a small animal-like good-old hand device and everytime got the funny pasting result by hitting [p].
On the jEdit program which is one of the new generation of the text editors on Linux, you have [rectangular select] and [clipboard extension]>>[vertical paste] menu items under the [[Edit]] primary menu. This "vertical paste" thing did the task I wanted long perfectly.
I shall use the jEdit editor when some table-like editing operation is needed.
Any way, thanks very much for your valuable helps. Thanks again.
If you were to actually, correctly, use CTRL+V to select the text you copied, then Vim will AUTOMATICALLY do a "vertical paste".
Either you aren't following directions, or you have a mapping interfering. You shouldn't need a different editor to do this. It's built into Vim and has been for years.
Oh Ben, you are right.
This morning I tried to do THE same task by using ONLY vim key commands like [h][j][k][l] for cursor movement, then I got the perfect desired result i.e. a vertical pasting. The lesson I may have learned is "don't use mouse for cursor movement for gvim rectangular operations", and, "You only should use those venerable vim key commands".
I prefer an appropriate set of menu items and mouse operations, though. Gvim must be a GUIed vim.
Thanks, any way.
Use Alt-LMB (Left Mouse Button) to do a VISUAL BLOCK selection.
Add two spaces, and do a paste...
Does not seem like a portable solution. For example, in Debian + KDE
+ drags the window as mouse moves along.
Kamaraju may be right. It doesn't work on my environment which is Linux/Ubuntu too. Did KF mean a Windows environment, or ...?
I'm on Windows, maybe this will help for KDE/Genome:
" .vimrc settings...
" Alt-Mouse-Left for block selections
" You need to disable/switch the Alt key for KDE/Gnome (Windowsettings for KDE)
nmap <A-LeftMouse> ms<LeftMouse><C-q>`so
imap <A-LeftMouse> <Esc><C-q>`^ms<Esc>gi<LeftMouse><C-o><C-q>`so
vmap <A-LeftDrag> <LeftDrag>
vmap <A-LeftMouse> <C-q>
See ":help gui-mouse-select".
It says "quadruple clicking makes it rectangular block-wise."
Thanks for giving us one of the deepest esoterica of the gvim editor.
But we somehow feel the four consecutive mouse clicks on a same position and in a very short time so horrible that we haven't tried them yet. When a good time should come someday, we'd surely try them, though.
A quick note:
I find P more useful than p because of columns' typical left-alignment and my desire to not mangle the tailend of my paste destination.
Also, 1v is very useful when dealing with blocks (:he visual-start), especially when transposing blocks / overwriting blocks.