pymode.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. *pymode.txt* *python-mode.txt* Python-mode for vim!
  2. ____ _ _ ____ _ _ _____ _ _ __ __ _____ ____ ____ ~
  3. ( _ \( \/ )(_ _)( )_( )( _ )( \( )___( \/ )( _ )( _ \( ___) ~
  4. )___/ \ / )( ) _ ( )(_)( ) ((___)) ( )(_)( )(_) ))__) ~
  5. (__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~
  6. Version: 0.6.9
  7. ==============================================================================
  8. CONTENTS *Python-mode-contents*
  9. 1.Intro...................................|PythonMode|
  10. 2.Options.................................|PythonModeOptions|
  11. 2.1.Customisation details.............|PythonModeOptionsDetails|
  12. 2.2.Modeline..........................|PythonModeModeline|
  13. 3.Default Keys............................|PythonModeKeys|
  14. 4.Commands................................|PythonModeCommands|
  15. 5.FAQ.....................................|PythonModeFAQ|
  16. 6.Credits.................................|PythonModeCredits|
  17. 7.License.................................|PythonModeLicense|
  18. ==============================================================================
  19. 1. Intro ~
  20. *PythonMode*
  21. Python-mode is a vim plugin that allows you to use the pylint, rope, and pydoc
  22. libraries in vim to provide features like python code bug checking,
  23. refactoring, and some other useful things.
  24. This plugin allow you create python code in vim very easily. There is no need
  25. to install the pylint or rope libraries on your system.
  26. ==============================================================================
  27. 2. Options ~
  28. *PythonModeOptions*
  29. Note:
  30. Pylint options (ex. disable messages) may be defined in '$HOME/pylint.rc'
  31. See pylint documentation.
  32. This script provides the following options that can customise the behaviour of
  33. PythonMode. These options should be set in your vimrc.
  34. |'pymode_paths'| Additional python paths for pymode
  35. |'pymode_doc'| Turns off the documentation script
  36. |'pymode_doc_key'| Key for show documentation
  37. |'pymode_run'| Turns off the run code script
  38. |'pymode_run_key'| Key for run python code
  39. |'pymode_lint'| Turns off pylint script
  40. |'pymode_lint_checker'| Switch code checkers (pylint, pyflakes, pep8, mccabe)
  41. |'pymode_lint_ignore'| Skip errors and warnings
  42. |'pymode_lint_select'| Select errors and warnings
  43. |'pymode_lint_onfly'| Run linter on the fly
  44. |'pymode_lint_config'| Filepath to pylint configuration
  45. |'pymode_lint_write'| Check code every save
  46. |'pymode_lint_cwindow'| Show cwindow
  47. |'pymode_lint_message'| Show current line errors in bottom
  48. |'pymode_lint_signs'| Place signs
  49. |'pymode_lint_jump'| Auto jump to first error
  50. |'pymode_lint_hold'| Hold cursor in current window
  51. |'pymode_lint_minheight'| Minimal height of pylint error window
  52. |'pymode_lint_mccabe_complexity'| Maximum allowed mccabe complexity
  53. |'pymode_lint_maxheight'| Maximal height of pylint error window
  54. |'pymode_rope'| Turns off rope script
  55. |'pymode_folding'| Turns on/off python folding
  56. |'pymode_breakpoint'| Turns off breakpoint script
  57. |'pymode_breakpoint_key'| Key for breakpoint
  58. |'pymode_virtualenv'| Turns off virtualenv
  59. |'pymode_utils_whitespaces'| Remove unused whitespaces
  60. |'pymode_syntax'| Turns off the custom syntax highlighting
  61. |'pymode_indent'| Enable/Disable pymode PEP8 indentation
  62. |'pymode_options'| Set default pymode options for
  63. python codding
  64. |'pymode_motion'| Enable pymode motion stuff
  65. Note:
  66. Also see |ropevim.txt|
  67. ------------------------------------------------------------------------------
  68. 2.1. Customisation details ~
  69. *PythonModeOptionsDetails*
  70. To enable any of the options below you should put the given line in your
  71. '$HOME/.vimrc'. See |vimrc-intro|.
  72. ------------------------------------------------------------------------------
  73. 2.2. Modeline ~
  74. *PythonModeModeline*
  75. Feature like VIM modeline `:help modeline`. Allow changing pymode options for
  76. edited file. Pymode modeline should always be the last line in the file and
  77. look like:
  78. >
  79. # pymode:lint_ignore=E0202:doc=0:lint_write=0
  80. <
  81. Examples:
  82. Disable folding on current file:
  83. >
  84. # pymode:folding=0
  85. <
  86. Set linters and mccabe complexity.
  87. >
  88. # pymode:lint_checker=pip,mccabe:lint_mccabe_complexity=10
  89. <
  90. This changes will work only in current buffer.
  91. ------------------------------------------------------------------------------
  92. *'pymode_paths'*
  93. Values: List of strings
  94. Default: [].
  95. This option set additional python import paths
  96. ------------------------------------------------------------------------------
  97. *'pymode_doc'*
  98. Values: 0 or 1.
  99. Default: 1.
  100. If this option is set to 0 then the doc script is disabled.
  101. ------------------------------------------------------------------------------
  102. *'pymode_doc_key'*
  103. Default: 'K'.
  104. Set key for show python documentation.
  105. ------------------------------------------------------------------------------
  106. *'pymode_run'*
  107. Values: 0 or 1.
  108. Default: 1.
  109. If this option is set to 0 then run script is disabled.
  110. ------------------------------------------------------------------------------
  111. *'pymode_run_key'*
  112. Default: '<leader>r'.
  113. Set key for run python code.
  114. ------------------------------------------------------------------------------
  115. *'pymode_lint'*
  116. Values: 0 or 1.
  117. Default: 1.
  118. If this option is set to 0 then the pylint script is disabled.
  119. ------------------------------------------------------------------------------
  120. *'pymode_lint_checker'*
  121. Values: "pylint", "pyflakes", "pep8", "mccabe"
  122. You can set many checkers. E.g. "pyflakes,pep8,mccabe" ~
  123. Default: "pyflakes,pep8,mccabe".
  124. This option sets code checkers.
  125. ------------------------------------------------------------------------------
  126. *'pymode_lint_ignore'*
  127. Values: IDs of errors, separated by commas or empty strings
  128. E.g. "E501,W002", "E2,W" (Skip all Warnings and Errors startswith E2) and etc ~
  129. Default: "E501".
  130. Skip errors and warnings.
  131. See also: |'pymode_lint_select'|, |'pymode_lint_config'|
  132. ------------------------------------------------------------------------------
  133. *'pymode_lint_select'*
  134. Values: IDs of errors, separated by commas or empty strings
  135. E.g. "W002,C" Force W002 and all C-ids ~
  136. Default: "".
  137. Select errors and warnings.
  138. See also: |'pymode_lint_ignore'|, |'pymode_lint_config'|
  139. ------------------------------------------------------------------------------
  140. *'pymode_lint_onfly'*
  141. Values: 0 or 1
  142. Default: 0
  143. This option enables "on the fly" code checking
  144. ------------------------------------------------------------------------------
  145. *'pymode_lint_config'*
  146. Values: 'Path to pylint configuration file'
  147. Default: "$HOME/.pylintrc"
  148. This option sets the path to the pylint configuration file. If the
  149. file is not found, use the 'pylintrc' file from python-mode sources.
  150. See also: |'pymode_lint_ignore'|, |'pymode_lint_select'|
  151. ------------------------------------------------------------------------------
  152. *'pymode_lint_write'*
  153. Values: 0 or 1.
  154. Default: 1.
  155. If this option is set to 0, then pylint auto-checking on every save is
  156. disabled.
  157. ------------------------------------------------------------------------------
  158. *'pymode_lint_cwindow'*
  159. Values: 0 or 1.
  160. Default: 1.
  161. If this option is set to 0 then pylint will not show cwindow.
  162. ------------------------------------------------------------------------------
  163. *'pymode_lint_message'*
  164. Values: 0 or 1.
  165. Default: 1.
  166. If this option is set to 0 then pylint will not show errors at bottom.
  167. ------------------------------------------------------------------------------
  168. *'pymode_lint_signs'*
  169. Values: 0 or 1.
  170. Default: 1.
  171. If this option is set to 0 then pylint will not place error signs.
  172. ------------------------------------------------------------------------------
  173. *'pymode_lint_jump'*
  174. Values: 0 or 1.
  175. Default: 0.
  176. If this option is set to 0 then pylint will not jump to the first error.
  177. ------------------------------------------------------------------------------
  178. *'pymode_lint_hold'*
  179. Values: 0 or 1.
  180. Default: 0.
  181. If this option is set to 0 then pylint will switch on the quickfix window when
  182. it opens. Doesn't work when |'pymode_lint_jump'| enabled.
  183. ------------------------------------------------------------------------------
  184. *'pymode_lint_minheight'*
  185. Values: int
  186. Default: 3.
  187. Set minimal height for the pylint cwindow.
  188. ------------------------------------------------------------------------------
  189. *'pymode_lint_mccabe_complexity'*
  190. Values: int
  191. Default: 8.
  192. Set minimal complexity for the mccabe linter.
  193. ------------------------------------------------------------------------------
  194. *'pymode_lint_maxheight'*
  195. Values: int
  196. Default: 6.
  197. Set maximal height for the pylint cwindow.
  198. ------------------------------------------------------------------------------
  199. *'pymode_rope'*
  200. Values: 0 or 1.
  201. Default: 1.
  202. If this option is set to 0 then the rope script is disabled.
  203. ------------------------------------------------------------------------------
  204. *'pymode_breakpoint'*
  205. Values: 0 or 1.
  206. Default: 1.
  207. If this option is set to 0 then the breakpoint script is disabled.
  208. ------------------------------------------------------------------------------
  209. *'pymode_breakpoint_key'*
  210. Default: '<leader>b'.
  211. Key for setting/unsetting breakpoints.
  212. ------------------------------------------------------------------------------
  213. *'pymode_virtualenv'*
  214. Values: 0 or 1.
  215. Default: 1.
  216. If this option is set to 0 then virtualenv support is disabled.
  217. ------------------------------------------------------------------------------
  218. *'pymode_utils_whitespaces'*
  219. Values: 0 or 1.
  220. Default: 1.
  221. Auto-remove unused whitespaces.
  222. ------------------------------------------------------------------------------
  223. *'pymode_syntax'*
  224. Values: 0 or 1.
  225. Default: 1.
  226. If this option is set to 0 then the custom syntax highlighting will
  227. not be used.
  228. ------------------------------------------------------------------------------
  229. *'pymode_indent'*
  230. Values: 0 or 1.
  231. Default: 1.
  232. If this option is set to 1, pymode will enable python indentation support
  233. ------------------------------------------------------------------------------
  234. *'pymode_folding'*
  235. Values: 0 or 1.
  236. Default: 1.
  237. If this option is set to 1, pymode will enable python-folding.
  238. ------------------------------------------------------------------------------
  239. *'pymode_options'*
  240. Values: 0 or 1.
  241. Default: 1.
  242. If this option is set to 1, pymode will enable the following options for python
  243. buffers: >
  244. setlocal complete+=t
  245. setlocal formatoptions-=t
  246. setlocal number
  247. setlocal nowrap
  248. setlocal textwidth=80
  249. <
  250. ------------------------------------------------------------------------------
  251. *'pymode_motion'*
  252. Values: 0 or 1.
  253. Default: 1.
  254. If this option is set to 1, pymode will enable some python motions.
  255. Pymode-motion is beta.
  256. ================ ============================
  257. Key Command
  258. ================ ============================
  259. [[ Jump to previous class or function (normal, visual, operator modes)
  260. ]] Jump to next class or function (normal, visual, operator modes)
  261. [M Jump to previous class or method (normal, visual, operator modes)
  262. ]M Jump to next class or method (normal, visual, operator modes)
  263. aC Select a class. Ex: vaC, daC, yaC, caC (normal, operator modes)
  264. iC Select inner class. Ex: viC, diC, yiC, ciC (normal, operator modes)
  265. aM Select a function or method. Ex: vaM, daM, yaM, caM (normal, operator modes)
  266. iM Select inner function or method. Ex: viM, diM, yiM, ciM (normal, operator modes)
  267. ================ ============================
  268. ==============================================================================
  269. 3. Default Keys ~
  270. *PythonModeKeys*
  271. To redefine keys, see: |PythonModeOptions|
  272. ================ ============================
  273. Key Command
  274. ================ ============================
  275. K Show python docs for current word under cursor
  276. C-Space Rope code assist
  277. <leader>r Run current buffer
  278. <leader>b Set breakpoints
  279. [[ Jump to previous class or function (normal, visual, operator modes)
  280. ]] Jump to next class or function (normal, visual, operator modes)
  281. [M Jump to previous class or method (normal, visual, operator modes)
  282. ]M Jump to next class or method (normal, visual, operator modes)
  283. aC C Operation with a class.
  284. Ex: vaC, daC, dC, yaC, yC, caC, cC (normal, operator modes)
  285. iC Operation with inner class.
  286. Ex: viC, diC, yiC, ciC (normal, operator modes)
  287. aM M Operation with function or method.
  288. Ex: vaM, daM, dM, yaM, yM, caM, cM (normal, operator modes)
  289. iM Operation with inner function or method.
  290. Ex: viM, diM, yiM, ciM (normal, operator modes)
  291. ================ ============================
  292. Note:
  293. Also see: |RopeShortcuts|
  294. ==============================================================================
  295. 4. Commands ~
  296. *PythonModeCommands*
  297. *:Pydoc* <args> *Pydoc*
  298. Show python documentation
  299. *:PyLintToggle* *PyLintToggle*
  300. Enable, disable pylint
  301. *:PyLint* *PyLint*
  302. Check current buffer
  303. *:PyLintAuto* *PyLintAuto*
  304. Automatically fix PEP8 errors in the current buffer
  305. *:Pyrun* *Pyrun*
  306. Run current buffer
  307. ==============================================================================
  308. 5. FAQ ~
  309. *PythonModeFAQ*
  310. Python-mode doesn't work
  311. ------------------------
  312. Run ":call pymode#troubleshooting#Test()" and fix the warning or send me the
  313. output.
  314. Rope completion is very slow
  315. ----------------------------
  316. To work, rope_ creates a service directory: `.ropeproject`. If
  317. |'pymode_rope_guess_project'| is set on (as it is by default) and
  318. `.ropeproject` is not found in the current dir, rope will scan for
  319. `.ropeproject` in every dir in the parent path. If rope finds `.ropeproject`
  320. in parent dirs, rope sets project for all child dir and the scan may be slow
  321. for many dirs and files.
  322. Solutions:
  323. - Disable |'pymode_rope_guess_project'| to make rope always create
  324. `.ropeproject` in the current dir.
  325. - Delete `.ropeproject` from the parent dir to make rope create `.ropeproject`
  326. in the current dir.
  327. - Press `<C-x>po` or `:RopeOpenProject` to force rope to create `.ropeproject`
  328. in the current dir.
  329. Pylint check is very slow
  330. -------------------------
  331. In some projects pylint_ may check slowly, because it also scan imported
  332. modules if possible. Try using pyflakes: see |'pymode_lint_checker'|.
  333. You may set |exrc| and |secure| in your |vimrc| to auto-set custom settings
  334. from `.vimrc` from your projects directories.
  335. >
  336. Example: On Flask projects I automatically set
  337. 'g:pymode_lint_checker = "pyflakes"'.
  338. On Django 'g:pymode_lint_checker = "pylint"'
  339. <
  340. OSX cannot import urandom
  341. -------------------------
  342. See: https://groups.google.com/forum/?fromgroups=#!topic/vim_dev/2NXKF6kDONo
  343. The sequence of commands that fixed this:
  344. >
  345. brew unlink python
  346. brew unlink macvim
  347. brew remove macvim
  348. brew install -v --force macvim
  349. brew link macvim
  350. brew link python
  351. <
  352. ==============================================================================
  353. 6. Credits ~
  354. *PythonModeCredits*
  355. Kirill Klenov
  356. http://klen.github.com/
  357. http://github.com/klen/
  358. Rope
  359. Copyright (C) 2006-2010 Ali Gholami Rudi
  360. Copyright (C) 2009-2010 Anton Gritsay
  361. Pylint
  362. Copyright (C) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
  363. http://www.logilab.fr/
  364. Pyflakes:
  365. Copyright (c) 2005 Divmod, Inc.
  366. http://www.divmod.com/
  367. PEP8:
  368. Copyright (c) 2006 Johann C. Rocholl <johann@rocholl.net>
  369. http://github.com/jcrocholl/pep8
  370. autopep8:
  371. Copyright (c) 2012 hhatto <hhatto.jp@gmail.com>
  372. https://github.com/hhatto/autopep8
  373. Python syntax for vim:
  374. Copyright (c) 2010 Dmitry Vasiliev
  375. http://www.hlabs.spb.ru/vim/python.vim
  376. PEP8 VIM indentation
  377. Copyright (c) 2012 Hynek Schlawack <hs@ox.cx>
  378. http://github.com/hynek/vim-python-pep8-indent
  379. ==============================================================================
  380. 7. License ~
  381. *PythonModeLicense*
  382. Python-mode is released under the GNU lesser general public license.
  383. See: http://www.gnu.org/copyleft/lesser.html
  384. If you like this plugin, you can send me a postcard :)
  385. My address is: "Russia, 143401, Krasnogorsk, Shkolnaya 1-19" to "Kirill Klenov".
  386. Thanks for your support!
  387. ------------------------------------------------------------------------------
  388. vim:tw=78:ts=8:ft=help:norl: