user862010
user862010

Reputation:

Vim move line up,down,left,right

In netbeans with CTRL+LEFT, CTRL+UP, CTRL+RIGHT, CTRL+DOWN we can move the line and it contents to LEFT, UP, RIGHT, DOWN ... how can I do this with vim !?

In linux netbeans is ALT+SHIFT ARROW LEFT, RIGHT to move !

Upvotes: 1

Views: 2601

Answers (3)

Ambidextrous
Ambidextrous

Reputation: 820

Adding to Zenzen's answer, you can do for example Esc+5+<< to have 5 lines below the cursor shifted to the left by a tab space.

Upvotes: 0

suhair
suhair

Reputation: 10949

The following key maps your indentions in a Vim way (using alt + j and k keys) and formats the moved lines as according to their new position. Code stolen from http://vim.wikia.com/wiki/Moving_lines_up_or_down.

nnoremap <A-j> :m+<CR>==
nnoremap <A-k> :m-2<CR>==
inoremap <A-j> <Esc>:m+<CR>==gi
inoremap <A-k> <Esc>:m-2<CR>==gi
vnoremap <A-j> :m'>+<CR>gv=gv
vnoremap <A-k> :m-2<CR>gv=gv

Upvotes: 2

Mateusz Dymczyk
Mateusz Dymczyk

Reputation: 15141

Well I do not have NetBeans but I guess (after googling) that by ctrl+right/left you mean to indent the selected block?

In that case you can use the >> and << commands. Just either go the line you want to indent or select a block (using "v") and press > twice (remember about the shift key :)).

The others (move up/down) are clearly described here.

Hope that's what you're looking for!

Upvotes: 1

Related Questions