Skip to content

Instantly share code, notes, and snippets.

@berinhard
Created April 13, 2011 12:16
Show Gist options
  • Save berinhard/917440 to your computer and use it in GitHub Desktop.
Save berinhard/917440 to your computer and use it in GitHub Desktop.
A script to enable walking lines to your vim
python << EOF
import vim
def line_up():
current_line_number = int(vim.eval('line(".")'))
current_line = vim.current.line
dest_line_number = current_line_number - 1
if current_line_number != 1:
vim.current.buffer.append(current_line, dest_line_number - 1)
op = str(current_line_number + 1) + 'd'
vim.command(op)
vim.command(str(dest_line_number))
def line_down():
current_line_number = int(vim.eval('line(".")'))
current_line = vim.current.line
dest_line_number = current_line_number + 1
if current_line_number != len(vim.current.buffer):
vim.current.buffer.append(current_line, dest_line_number)
op = str(current_line_number) + 'd'
vim.command(op)
vim.command(str(dest_line_number))
vim.command('map <C-Up> :py line_up()<cr>')
vim.command('map <C-Down> :py line_down()<cr>')
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment