|
| 1 | +vim-python-pep8-indent.txt |
| 2 | + |
| 3 | +================================================================================ |
| 4 | +CONTENTS *vim-python-pep8-indent-contents* |
| 5 | + |
| 6 | +1. vim-python-pep8-indent..........|vim-python-pep8-indent-vim-python-pep8-indent| |
| 7 | + 1.1. Installation........................|vim-python-pep8-indent-installation| |
| 8 | + 1.1.1. Pathogen..........................|vim-python-pep8-indent-pathogen| |
| 9 | + 1.1.2. Vundle..............................|vim-python-pep8-indent-vundle| |
| 10 | + 1.1.3. NeoBundle........................|vim-python-pep8-indent-neobundle| |
| 11 | + 1.2. Configuration......................|vim-python-pep8-indent-configuration| |
| 12 | + 1.2.1. g:python_pep8_indent_multiline_string.|vim-python-pep8-indent-g:python_pep8_indent_multiline_string| |
| 13 | + 1.2.2. g:python_pep8_indent_hang_closing.|vim-python-pep8-indent-g:python_pep8_indent_hang_closing| |
| 14 | + 1.3. Troubleshooting..................|vim-python-pep8-indent-troubleshooting| |
| 15 | + 1.4. Notes......................................|vim-python-pep8-indent-notes| |
| 16 | + 1.5. License and Authorship....|vim-python-pep8-indent-license_and_authorship| |
| 17 | + |
| 18 | +================================================================================ |
| 19 | +VIM-PYTHON-PEP8-INDENT *vim-python-pep8-indent-vim-python-pep8-indent* |
| 20 | + |
| 21 | +[](https://circleci.com/gh/Vimjas/vim-python-pep8-indent) |
| 22 | + |
| 23 | +[](https://codecov.io/gh/Vimjas/vim-python-pep8-indent) |
| 24 | + |
| 25 | +This small script modifies Vim (http://www.vim.org/)'s indentation |
| 26 | +behavior to comply with PEP8 (http://www.python.org/dev/peps/pep-0008/) |
| 27 | +and my aesthetic preferences. Most importantly: |
| 28 | +> |
| 29 | + foobar(foo, |
| 30 | + bar) |
| 31 | +< |
| 32 | + |
| 33 | +and: |
| 34 | +> |
| 35 | + foobar( |
| 36 | + foo, |
| 37 | + bar |
| 38 | + ) |
| 39 | +< |
| 40 | + |
| 41 | +-------------------------------------------------------------------------------- |
| 42 | +INSTALLATION *vim-python-pep8-indent-installation* |
| 43 | + |
| 44 | +Install the plugin using your favorite plugin manager / method, a few |
| 45 | +examples follow: |
| 46 | + |
| 47 | +PATHOGEN *vim-python-pep8-indent-pathogen* |
| 48 | + |
| 49 | +Follow the instructions on installing |
| 50 | +Pathogen (https://github.com/tpope/vim-pathogen) and then: |
| 51 | +> |
| 52 | + $ cd ~/.vim/bundle |
| 53 | + $ git clone https://github.com/Vimjas/vim-python-pep8-indent.git |
| 54 | +< |
| 55 | + |
| 56 | +VUNDLE *vim-python-pep8-indent-vundle* |
| 57 | + |
| 58 | +Follow the instructions on installing |
| 59 | +Vundle (https://github.com/gmarik/Vundle.vim) and add the appropriate |
| 60 | +plugin line into your `.vimrc`: |
| 61 | +> |
| 62 | + Plugin 'Vimjas/vim-python-pep8-indent' |
| 63 | +< |
| 64 | + |
| 65 | +NEOBUNDLE *vim-python-pep8-indent-neobundle* |
| 66 | + |
| 67 | +Follow the instructions on installing |
| 68 | +NeoBundle (https://github.com/Shougo/neobundle.vim) and add the |
| 69 | +appropriate NeoBundle line into your `.vimrc`: |
| 70 | +> |
| 71 | + NeoBundle 'Vimjas/vim-python-pep8-indent' |
| 72 | +< |
| 73 | + |
| 74 | +-------------------------------------------------------------------------------- |
| 75 | +CONFIGURATION *vim-python-pep8-indent-configuration* |
| 76 | + |
| 77 | +G:PYTHON_PEP8_INDENT_MULTILINE_STRING *vim-python-pep8-indent-g:python_pep8_indent_multiline_string* |
| 78 | + |
| 79 | +You can configure the initial indentation of multiline strings using |
| 80 | +`g:python_pep8_indent_multiline_string` (which can also be set per |
| 81 | +buffer). This defaults to `0`, which means that multiline strings are |
| 82 | +not indented. `-1` and positive values will be used as-is, where `-1` is |
| 83 | +a special value for Vim\'s `indentexpr`, and will keep the existing |
| 84 | +indent (using Vim\'s `autoindent` setting). `-2` is meant to be used for |
| 85 | +strings that are wrapped with `textwrap.dedent` etc. It will add a level |
| 86 | +of indentation if the multiline string started in the previous line, |
| 87 | +without any content in it already: |
| 88 | +> |
| 89 | + testdir.makeconftest(""" |
| 90 | + _ |
| 91 | +< |
| 92 | + |
| 93 | +With content already, it will be aligned to the opening parenthesis: |
| 94 | +> |
| 95 | + testdir.makeconftest("""def pytest_addoption(parser): |
| 96 | + _ |
| 97 | +< |
| 98 | + |
| 99 | +Existing indentation (including `0`) in multiline strings will be kept, |
| 100 | +so this setting only applies to the indentation of new/empty lines. |
| 101 | + |
| 102 | +G:PYTHON_PEP8_INDENT_HANG_CLOSING *vim-python-pep8-indent-g:python_pep8_indent_hang_closing* |
| 103 | + |
| 104 | +Control closing bracket indentation with |
| 105 | +`python_pep8_indent_hang_closing`, set globally or per buffer. |
| 106 | + |
| 107 | +By default (set to `0`), closing brackets line up with the opening line: |
| 108 | +> |
| 109 | + my_list = [ |
| 110 | + 1, 2, 3, |
| 111 | + 4, 5, 6, |
| 112 | + ] |
| 113 | + result = some_function_that_takes_arguments( |
| 114 | + 'a', 'b', 'c', |
| 115 | + 'd', 'e', 'f', |
| 116 | + ) |
| 117 | +< |
| 118 | + |
| 119 | +With , closing brackets line up |
| 120 | +with the items: |
| 121 | +> |
| 122 | + my_list = [ |
| 123 | + 1, 2, 3, |
| 124 | + 4, 5, 6, |
| 125 | + ] |
| 126 | + result = some_function_that_takes_arguments( |
| 127 | + 'a', 'b', 'c', |
| 128 | + 'd', 'e', 'f', |
| 129 | + ) |
| 130 | +< |
| 131 | + |
| 132 | +-------------------------------------------------------------------------------- |
| 133 | +TROUBLESHOOTING *vim-python-pep8-indent-troubleshooting* |
| 134 | + |
| 135 | +In case it is not working, please make sure your Vim is configured to |
| 136 | +load indent files (). This is typically the case |
| 137 | +when using a plugin manager, but check its docs. |
| 138 | + |
| 139 | +Check in a Python file, which should show |
| 140 | +something like the following: |
| 141 | +> |
| 142 | + indentexpr=GetPythonPEPIndent(v:lnum) |
| 143 | + : Last set from |
| 144 | + ~/.../plugged/vim-python-pep8-indent/indent/python.vim |
| 145 | +< |
| 146 | + |
| 147 | +-------------------------------------------------------------------------------- |
| 148 | +NOTES *vim-python-pep8-indent-notes* |
| 149 | + |
| 150 | +Please note that Kirill Klenov's |
| 151 | +python-mode (https://github.com/klen/python-mode) ships its own version |
| 152 | +of this bundle. Therefore, if you want to use this version specifically, |
| 153 | +you'll have to disable python-mode's using: |
| 154 | +> |
| 155 | + let g:pymode_indent = 0 |
| 156 | +< |
| 157 | + |
| 158 | +-------------------------------------------------------------------------------- |
| 159 | +LICENSE AND AUTHORSHIP *vim-python-pep8-indent-license_and_authorship* |
| 160 | + |
| 161 | +This script is based on one from Vim's official script |
| 162 | +repo (http://www.vim.org/scripts/script.php?script_id=974) that was |
| 163 | +not originally written by me. Unfortunately the indentation was off by |
| 164 | +one character in one case and the script hasn't been updated since 2005. |
| 165 | + |
| 166 | +Even more unfortunately, I wasn't able to reach any of the original |
| 167 | +authors/maintainers: David Bustos and Eric Mc Sween. |
| 168 | + |
| 169 | +So I fixed the annoyance with the help of Steve |
| 170 | +Losh (http://stevelosh.com/) and am putting it out here so you don't |
| 171 | +have to patch the original yourself. The original patch is still |
| 172 | +available here (https://gist.github.com/2965846). |
| 173 | + |
| 174 | +Over the time a lot more improvements have been |
| 175 | +contributed (https://github.com/hynek/vim-python-pep8-indent/blob/master/CONTRIBUTING.rst) |
| 176 | +by generous |
| 177 | +people (https://github.com/hynek/vim-python-pep8-indent/graphs/contributors). |
| 178 | + |
| 179 | +I'd like to thank the original authors here for their work and release |
| 180 | +it hereby to the Public Domain (using the |
| 181 | +CC0 (http://creativecommons.org/publicdomain/zero/1.0/) licence) since |
| 182 | +I hope that would be in their spirit. If anyone with a say in this |
| 183 | +objects, please let me (https://hynek.me/) know immediately. Also, if |
| 184 | +someone is in contact with one of them, I would appreciate being |
| 185 | +introduced. |
| 186 | + |
| 187 | +While my Vimscript (http://learnvimscriptthehardway.stevelosh.com/) |
| 188 | +skills are still feeble, I intend to maintain it for now. This mainly |
| 189 | +means that I'll triage through bugs and pull requests but won't be |
| 190 | +fixing much myself. |
| 191 | + |
| 192 | + vim:tw=78:ts=8:ft=help:norl: |
0 commit comments