Created
April 13, 2011 12:16
-
-
Save berinhard/917440 to your computer and use it in GitHub Desktop.
A script to enable walking lines to your vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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