ivan
ivan

Reputation: 6322

How can I force a Vim command to run silently?

I have some keymappings in my vimrc for moving entire lines up/down. For example,

nnoremap <D-J> :move .+1<CR>==

moves a line down (swapping with the line below it). It echoes the command, :move .+1, at the command line, and I'd like to silence that. I've tried

nnoremap <silent> ,<D-J> :move .+1<CR>==

and

nnoremap <silent> ,<D-J> :exe ":silent normal move .+1"<CR>==

but neither had any effect. Is there a way to do this?

Upvotes: 1

Views: 1552

Answers (1)

cforbish
cforbish

Reputation: 8819

I tried these mappings to move up with control k and down with control j using visual mode for moving multiple lines:

nnoremap <silent> <C-J> :move .+1<CR>
nnoremap <silent> <C-K> :move .-2<CR>
vnoremap <silent> <C-J> :move '>+1<CR>:normal gv<CR>
vnoremap <silent> <C-K> :move '<-2<CR>:normal gv<CR>

Upvotes: 1

Related Questions