Last active
October 10, 2015 21:31
-
-
Save shanechin/ce7b086421e8387193fd to your computer and use it in GitHub Desktop.
Some python .vimrc examples
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
from snake import * | |
import pyperclip | |
from sh import xdotool | |
import random | |
import string | |
@key_map("<leader>l") | |
def log(): | |
''' | |
Function will allow you to create a log line with a unique string, | |
via the 'print/echo/..' equivialent in the language you are currently editing | |
as determined by file type | |
''' | |
result = command('set filetype?', capture=True) | |
file_type = result.split('=')[1] | |
print_command = '' | |
if file_type == 'python': | |
print_command = 'print ' | |
keys("o"+ print_command + " '" + rand_string(5) + "'") | |
@key_map("<cr>") | |
def send_line(): | |
''' | |
Allows you to use your os in the same way many people use 'tmux/screen', | |
Send keys from vim to another python shell. | |
''' | |
pyperclip.copy(get_line()) | |
roshell_id = xdotool('search', '--name', 'django-roshell') | |
xdotool('key', '--window', roshell_id, 'F6') | |
xdotool('key', '--window', roshell_id, '--clearmodifiers', 'ctrl+shift+v') | |
xdotool('key', '--window', roshell_id, 'F6') | |
xdotool('key', '--window', roshell_id, 'Return') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment