Skip to content

Commit

Permalink
Merge pull request #6 from AguirreIF/add_auto_indent_option
Browse files Browse the repository at this point in the history
Add auto indent option
  • Loading branch information
matze committed Oct 15, 2013
2 parents 84c43d5 + 91f3ef5 commit 98ce670
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions doc/move.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ keys. Your can specify the key modifier that uses in key bindings with >
All mappings can be prefixed with a {count} and will move {count} steps
instead of one.

By default the plugin indents the buffer after every move operation. Can be
disabled with >
let g:move_auto_indent = 0
-------------------------------------------------------------------------------
2.1 <Plug>MoveBlockDown

Expand Down
20 changes: 16 additions & 4 deletions plugin/move.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if !exists('g:move_key_modifier')
let g:move_key_modifier = 'A'
endif

if !exists('g:move_auto_indent')
let g:move_auto_indent = 1
endif

function! s:ResetCursor()
normal! gv=gv^
endfunction
Expand Down Expand Up @@ -63,13 +67,17 @@ function! s:MoveLineUp(count) range

if (line('.') - distance) < 0
execute 'silent m 0'
normal! ==
if (g:move_auto_indent == 1)
normal! ==
endif
return
endif

execute 'silent m-' . distance

normal! ==
if (g:move_auto_indent == 1)
normal! ==
endif
endfunction

function! s:MoveLineDown(count) range
Expand All @@ -81,12 +89,16 @@ function! s:MoveLineDown(count) range

if (line('.') + distance) > line('$')
execute 'silent m $'
normal! ==
if (g:move_auto_indent == 1)
normal! ==
endif
return
endif

execute 'silent m+' . distance
normal! ==
if (g:move_auto_indent == 1)
normal! ==
endif
endfunction

function! s:MoveBlockOneLineUp() range
Expand Down

0 comments on commit 98ce670

Please sign in to comment.