<commit_before>"""Run autopep8 on the selected buffer in Vim.

map <C-I> :pyf <path_to>/autopep8_vim.py<CR>

"""

import autopep8
import vim


encoding = vim.eval('&fileencoding')
options = autopep8.parse_args(['--range',
                               str(vim.current.range.start),
                               str(vim.current.range.end),
                               ''])[0]

source = '\n'.join([line.decode(encoding)
                    for line in vim.current.buffer]) + '\n'

formatted = autopep8.fix_string(source, options=options)

if source != formatted:
    vim.current.buffer[:] = [line.encode(encoding)
                             for line in formatted.splitlines()]<commit_msg>Offset since line numbers to be index at 1<commit_after>"""Run autopep8 on the selected buffer in Vim.

map <C-I> :pyf <path_to>/autopep8_vim.py<CR>

"""

import autopep8
import vim


encoding = vim.eval('&fileencoding')
options = autopep8.parse_args(['--range',
                               str(1 + vim.current.range.start),
                               str(1 + vim.current.range.end),
                               ''])[0]

source = '\n'.join([line.decode(encoding)
                    for line in vim.current.buffer]) + '\n'

formatted = autopep8.fix_string(source, options=options)

if source != formatted:
    vim.current.buffer[:] = [line.encode(encoding)
                             for line in formatted.splitlines()]
{'fraction_non_alphanumeric': 0.13473684210526315, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 2.0405117270788913, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '471809', 'n_tokens_mistral': 452, 'n_tokens_neox': 437, 'n_words': 93}