This is for the wishlist. It would be nice to be able to run code directly from restructured text documents where the initial indentation is 2 or 3. For example
This is some sphinx documentation with examples:
.. ipython:: python
import os
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
dedent_run_these_lines() will not work on this -- because the indentation is
only three spaces. This is a quick hack I have to get it to work, if count == 0, then set count = 1 so it tries to indent. I'm sure there's a better way..
def dedent_run_these_lines():
r = vim.current.range
shiftwidth = vim.eval('&shiftwidth')
count = int(vim.eval('indent(%d+1)/%s' % (r.start,shiftwidth)))
if count == 0:
count = 1
if count > 0:
vim.command("'<,'>" + "<"*count)
run_these_lines()
if count > 0:
vim.command("silent undo")
This is for the wishlist. It would be nice to be able to run code directly from restructured text documents where the initial indentation is 2 or 3. For example
dedent_run_these_lines()
will not work on this -- because the indentation is only three spaces. This is a quick hack I have to get it to work, if count == 0, then set count = 1 so it tries to indent. I'm sure there's a better way..Thanks!