This repository was archived by the owner on Sep 1, 2023. It is now read-only.
forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpymode.txt
More file actions
718 lines (501 loc) · 25.1 KB
/
pymode.txt
File metadata and controls
718 lines (501 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
*pymode.txt* *python-mode.txt* Python-mode for vim!
____ _ _ ____ _ _ _____ _ _ __ __ _____ ____ ____ ~
( _ \( \/ )(_ _)( )_( )( _ )( \( )___( \/ )( _ )( _ \( ___) ~
)___/ \ / )( ) _ ( )(_)( ) ((___)) ( )(_)( )(_) ))__) ~
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~
Version: 0.6.18
==============================================================================
CONTENTS *Python-mode-contents*
1.Intro...................................|PythonMode|
2.Options.................................|PythonModeOptions|
2.1.Customisation details.............|PythonModeOptionsDetails|
2.2.Modeline..........................|PythonModeModeline|
3.Default Keys............................|PythonModeKeys|
4.Commands................................|PythonModeCommands|
5.Python 3................................|PythonModePython3|
6.FAQ.....................................|PythonModeFAQ|
7.Credits.................................|PythonModeCredits|
8.License.................................|PythonModeLicense|
==============================================================================
1. Intro ~
*PythonMode*
Python-mode is a vim plugin that allows you to use the pylint, rope, and pydoc
libraries in vim to provide features like python code bug checking,
refactoring, and some other useful things.
This plugin allows you to create python code in vim very easily. There is no need
to install the pylint or rope libraries on your system.
==============================================================================
2. Options ~
*PythonModeOptions*
Note:
Pylint options (ex. disable messages) may be defined in '$HOME/pylint.rc'
See pylint documentation.
This script provides the following options that can customise the behaviour of
PythonMode. These options should be set in your vimrc.
|'pymode'| Turn off the whole plugin
|'pymode_py3k'| Enable support for python 3
|'pymode_paths'| Additional python paths for pymode
|'pymode_py3k'| Enable support for python 3
|'pymode_doc'| Turns off the documentation script
|'pymode_doc_key'| Key for show documentation
|'pymode_run'| Turns off the run code script
|'pymode_run_key'| Key for run python code
|'pymode_lint'| Turns off pylint script
|'pymode_lint_checker'| Switch code checkers (pylint, pyflakes, pep8, mccabe)
|'pymode_lint_ignore'| Skip errors and warnings
|'pymode_lint_select'| Select errors and warnings
|'pymode_lint_onfly'| Run linter on the fly
|'pymode_lint_config'| Filepath to pylint configuration
|'pymode_lint_write'| Check code every save
|'pymode_lint_cwindow'| Show cwindow
|'pymode_lint_message'| Show current line errors in bottom
|'pymode_lint_signs'| Place signs
|'pymode_lint_jump'| Auto jump to first error
|'pymode_lint_hold'| Hold cursor in current window
|'pymode_lint_minheight'| Minimal height of pylint error window
|'pymode_lint_mccabe_complexity'| Maximum allowed mccabe complexity
|'pymode_lint_maxheight'| Maximal height of pylint error window
|'pymode_rope'| Turns off rope script
|'pymode_folding'| Turns on/off python folding
|'pymode_breakpoint'| Turns off breakpoint script
|'pymode_breakpoint_key'| Key for breakpoint
|'pymode_virtualenv'| Turns off virtualenv
|'pymode_utils_whitespaces'| Remove unused whitespaces
|'pymode_syntax'| Turns off the custom syntax highlighting
|'pymode_syntax_all'| Enable all hightlight groups
|'pymode_syntax_print_as_function'| Hightlight `print` as function
|'pymode_syntax_highlight_equal_operator'| Hightlight `=`
|'pymode_syntax_highlight_stars_operator'| Hightlight `*`
|'pymode_syntax_highlight_self'| Hightlight `self`
|'pymode_syntax_indent_errors'| Hightlight indentation errors
|'pymode_syntax_space_errors'| Hightlight trailing spaces as errors
|'pymode_syntax_string_formating'| Hightlight string formating
|'pymode_syntax_string_format'| Hightlight Str.format syntax
|'pymode_syntax_string_templates'| Hightlight string templates
|'pymode_syntax_doc_tests'| Hightlight doctests
|'pymode_syntax_builtin_objs'| Hightlight builtin objects
|'pymode_syntax_builtin_types'| Hightlight builtin types
|'pymode_syntax_builtin_functions'| Hightlight builtin functions
|'pymode_syntax_highlight_exceptions'| Hightlight builtin exceptions
|'pymode_indent'| Enable/Disable pymode PEP8 indentation
|'pymode_options'| Set default pymode options for
python codding
|'pymode_motion'| Enable pymode motion stuff
Note:
Also see |ropevim.txt|
------------------------------------------------------------------------------
2.1. Customisation details ~
*PythonModeOptionsDetails*
To enable any of the options below you should put the given line in your
'$HOME/.vimrc'. See |vimrc-intro|.
------------------------------------------------------------------------------
2.2. Modeline ~
*PythonModeModeline*
The VIM modeline `:help modeline` feature allows you to change pymode
options for the current file. Pymode modeline should always be the
last line in the vimrc file and look like:
>
# pymode:lint_ignore=E0202:doc=0:lint_write=0
<
Examples:
Disable folding on current file:
>
# pymode:folding=0
<
Set linters and mccabe complexity.
>
# pymode:lint_checker=pip,mccabe:lint_mccabe_complexity=10
<
These changes will work only in the current buffer.
------------------------------------------------------------------------------
*'pymode'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the whole plugin is disabled
------------------------------------------------------------------------------
*'pymode_py3k'*
Values: 0 or 1.
Default: 0.
If this option is set to 1 then python 3 support is enabled.
------------------------------------------------------------------------------
*'pymode_paths'*
Values: List of strings
Default: [].
This option sets additional python import paths
------------------------------------------------------------------------------
*'pymode_doc'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the doc script is disabled.
------------------------------------------------------------------------------
*'pymode_doc_key'*
Default: 'K'.
Set the key to show the show python documentation.
------------------------------------------------------------------------------
*'pymode_run'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the run script is disabled.
------------------------------------------------------------------------------
*'pymode_run_key'*
Default: '<leader>r'.
Set the key for running python code.
------------------------------------------------------------------------------
*'pymode_lint'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the pylint script is disabled.
------------------------------------------------------------------------------
*'pymode_lint_checker'*
Values: "pylint", "pyflakes", "pep8", "mccabe", "pep257"
You can set many checkers. E.g. "pyflakes,pep8,mccabe" ~
Default: "pyflakes,pep8,mccabe".
This option sets code checkers.
------------------------------------------------------------------------------
*'pymode_lint_ignore'*
Values: IDs of errors, separated by commas or empty strings
E.g. "E501,W002", "E2,W" (Skip all Warnings and Errors startswith E2) and etc ~
Default: "".
Skip errors and warnings.
See also: |'pymode_lint_select'|, |'pymode_lint_config'|
------------------------------------------------------------------------------
*'pymode_lint_select'*
Values: IDs of errors, separated by commas or empty strings
E.g. "W002,C" Force W002 and all C-ids ~
Default: "".
Select errors and warnings.
See also: |'pymode_lint_ignore'|, |'pymode_lint_config'|
------------------------------------------------------------------------------
*'pymode_lint_onfly'*
Values: 0 or 1
Default: 0
This option enables "on the fly" code checking
------------------------------------------------------------------------------
*'pymode_lint_config'*
Values: 'Path to pylint configuration file'
Default: "$HOME/.pylintrc"
This option sets the path to the pylint configuration file. If the
file is not found, use the 'pylintrc' file from python-mode sources.
See also: |'pymode_lint_ignore'|, |'pymode_lint_select'|
------------------------------------------------------------------------------
*'pymode_lint_write'*
Values: 0 or 1.
Default: 1.
If this option is set to 0, then pylint auto-checking on every save is
disabled.
------------------------------------------------------------------------------
*'pymode_lint_cwindow'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then pylint will not show cwindow.
------------------------------------------------------------------------------
*'pymode_lint_message'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then pylint will not show errors at bottom.
------------------------------------------------------------------------------
*'pymode_lint_signs'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then pylint will not place error signs.
------------------------------------------------------------------------------
*'pymode_lint_jump'*
Values: 0 or 1.
Default: 0.
If this option is set to 0 then pylint will not jump to the first error.
------------------------------------------------------------------------------
*'pymode_lint_hold'*
Values: 0 or 1.
Default: 0.
If this option is set to 0 then pylint will switch on the quickfix window when
it opens. Doesn't work when |'pymode_lint_jump'| is enabled.
------------------------------------------------------------------------------
*'pymode_lint_minheight'*
Values: int
Default: 3.
Set minimal height for the pylint cwindow.
------------------------------------------------------------------------------
*'pymode_lint_mccabe_complexity'*
Values: int
Default: 8.
Set minimal complexity for the mccabe linter.
------------------------------------------------------------------------------
*'pymode_lint_maxheight'*
Values: int
Default: 6.
Set maximal height for the pylint cwindow.
------------------------------------------------------------------------------
*'pymode_rope'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the rope script is disabled.
------------------------------------------------------------------------------
*'pymode_breakpoint'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the breakpoint script is disabled.
------------------------------------------------------------------------------
*'pymode_breakpoint_key'*
Default: '<leader>b'.
Key for setting/unsetting breakpoints.
------------------------------------------------------------------------------
*'pymode_virtualenv'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then virtualenv support is disabled.
------------------------------------------------------------------------------
*'pymode_utils_whitespaces'*
Values: 0 or 1.
Default: 1.
Auto-remove unused whitespaces.
------------------------------------------------------------------------------
*'pymode_syntax'*
Values: 0 or 1.
Default: 1.
If this option is set to 0 then the custom syntax highlighting will
not be used.
------------------------------------------------------------------------------
*'pymode_syntax_all'*
Values: 0 or 1.
Default: 1.
Enabling all hightlight groups.
------------------------------------------------------------------------------
*'pymode_syntax_print_as_function'*
Values: 0 or 1.
Default: 0.
Hightlight `print` as function
------------------------------------------------------------------------------
*'pymode_syntax_highlight_equal_operator'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight `=`
------------------------------------------------------------------------------
*'pymode_syntax_highlight_stars_operator'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight `*`
------------------------------------------------------------------------------
*'pymode_syntax_highlight_self'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight `self`
------------------------------------------------------------------------------
*'pymode_syntax_indent_errors'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight indentation errors
------------------------------------------------------------------------------
*'pymode_syntax_space_errors'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight trailing spaces as errors
------------------------------------------------------------------------------
*'pymode_syntax_string_formating'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight string formating
------------------------------------------------------------------------------
*'pymode_syntax_string_format'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight Str.format syntax
------------------------------------------------------------------------------
*'pymode_syntax_string_templates'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight string templates
------------------------------------------------------------------------------
*'pymode_syntax_string_doctests'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight doctests
------------------------------------------------------------------------------
*'pymode_syntax_builtin_objs'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight builtin objects
------------------------------------------------------------------------------
*'pymode_syntax_builtin_types'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight builtin types
------------------------------------------------------------------------------
*'pymode_syntax_builtin_functions'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight builtin functions
------------------------------------------------------------------------------
*'pymode_syntax_highlight_exceptions'*
Values: 0 or 1.
Default: |'pymode_syntax_all'|.
Hightlight builtin exceptions
------------------------------------------------------------------------------
*'pymode_indent'*
Values: 0 or 1.
Default: 1.
If this option is set to 1, pymode will enable python indentation support.
------------------------------------------------------------------------------
*'pymode_folding'*
Values: 0 or 1.
Default: 1.
If this option is set to 1, pymode will enable python-folding.
------------------------------------------------------------------------------
*'pymode_options'*
Values: 0 or 1.
Default: 1.
If this option is set to 1, pymode will enable the following options for python
buffers: >
setlocal complete+=t
setlocal formatoptions-=t
setlocal number
setlocal nowrap
setlocal textwidth=80
setlocal commentstring=#%s
<
------------------------------------------------------------------------------
*'pymode_motion'*
Values: 0 or 1.
Default: 1.
If this option is set to 1, pymode will enable some python motions.
Pymode-motion is beta.
================ ============================
Key Command
================ ============================
[[ Jump to previous class or function (normal, visual, operator modes)
]] Jump to next class or function (normal, visual, operator modes)
[M Jump to previous class or method (normal, visual, operator modes)
]M Jump to next class or method (normal, visual, operator modes)
aC Select a class. Ex: vaC, daC, yaC, caC (normal, operator modes)
iC Select inner class. Ex: viC, diC, yiC, ciC (normal, operator modes)
aM Select a function or method. Ex: vaM, daM, yaM, caM (normal, operator modes)
iM Select inner function or method. Ex: viM, diM, yiM, ciM (normal, operator modes)
================ ============================
==============================================================================
3. Default Keys ~
*PythonModeKeys*
To redefine keys, see: |PythonModeOptions|
================ ============================
Key Command
================ ============================
K Show python docs for current word under cursor (`g:pymode_doc_key`)
C-Space Rope code assist (`g:pymode_rope_autocomplete_map`)
<leader>r Run current buffer (`g:pymode_run_key`)
<leader>b Set breakpoints (`g:pymode_breakpoint_key`)
[[ Jump to previous class or function (normal, visual, operator modes)
]] Jump to next class or function (normal, visual, operator modes)
[M Jump to previous class or method (normal, visual, operator modes)
]M Jump to next class or method (normal, visual, operator modes)
aC C Operation with a class.
Ex: vaC, daC, dC, yaC, yC, caC, cC (normal, operator modes)
iC Operation with inner class.
Ex: viC, diC, yiC, ciC (normal, operator modes)
aM M Operation with function or method.
Ex: vaM, daM, dM, yaM, yM, caM, cM (normal, operator modes)
iM Operation with inner function or method.
Ex: viM, diM, yiM, ciM (normal, operator modes)
================ ============================
Note:
Also see: |RopeShortcuts|
==============================================================================
4. Commands ~
*PythonModeCommands*
*:Pydoc* <args> *Pydoc*
Show python documentation
*:PyLintToggle* *PyLintToggle*
Enable, disable pylint
*:PyLint* *PyLint*
Check current buffer
*:PyLintAuto* *PyLintAuto*
Automatically fix PEP8 errors in the current buffer
*:Pyrun* *Pyrun*
Run current buffer
==============================================================================
5. Python 3
*PythonModePython3*
Python-mode Python 3 support requires your vim to be compiled with python 3.
Please see |Python3| for more details.
Please refer |pymode_py3k| to enable python 3. Kindly note that python 3
feature support very preliminary at this moment, and only supports rope
plugin.
==============================================================================
6. FAQ ~
*PythonModeFAQ*
Python-mode doesn't work
------------------------
Open any python file and run ":call pymode#troubleshooting#Test()",
fix the warning or send me the output.
Rope completion is very slow
----------------------------
To work, rope_ creates a service directory: `.ropeproject`. If
|'pymode_rope_guess_project'| is set on (as it is by default) and
`.ropeproject` is not found in the current dir, rope will scan for
`.ropeproject` in every dir in the parent path. If rope finds `.ropeproject`
in parent dirs, rope sets projectis for all child dirs and the scan may be
slow for many dirs and files.
Solutions:
- Disable |'pymode_rope_guess_project'| to make rope always create
`.ropeproject` in the current dir.
- Delete `.ropeproject` from the parent dir to make rope create `.ropeproject`
in the current dir.
- Press `<C-x>po` or `:RopeOpenProject` to force rope to create `.ropeproject`
in the current dir.
Pylint check is very slow
-------------------------
In some projects pylint_ may check slowly, because it also scans imported
modules if possible. Try using pyflakes: see |'pymode_lint_checker'|.
You may set |exrc| and |secure| in your |vimrc| to auto-set custom settings
from `.vimrc` from your projects directories.
>
Example: On Flask projects I automatically set
'g:pymode_lint_checker = "pyflakes"'.
On Django 'g:pymode_lint_checker = "pylint"'
<
OSX cannot import urandom
-------------------------
See: https://groups.google.com/forum/?fromgroups=#!topic/vim_dev/2NXKF6kDONo
The sequence of commands that fixed this:
>
brew unlink python
brew unlink macvim
brew remove macvim
brew install -v --force macvim
brew link macvim
brew link python
<
==============================================================================
7. Credits ~
*PythonModeCredits*
Kirill Klenov
http://klen.github.com/
http://github.com/klen/
Rope
Copyright (C) 2006-2010 Ali Gholami Rudi
Copyright (C) 2009-2010 Anton Gritsay
Pylint
Copyright (C) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/
Pyflakes:
Copyright (c) 2005 Divmod, Inc.
http://www.divmod.com/
PEP8:
Copyright (c) 2006 Johann C. Rocholl <johann@rocholl.net>
http://github.com/jcrocholl/pep8
autopep8:
Copyright (c) 2012 hhatto <hhatto.jp@gmail.com>
https://github.com/hhatto/autopep8
Python syntax for vim:
Copyright (c) 2010 Dmitry Vasiliev
http://www.hlabs.spb.ru/vim/python.vim
PEP8 VIM indentation
Copyright (c) 2012 Hynek Schlawack <hs@ox.cx>
http://github.com/hynek/vim-python-pep8-indent
==============================================================================
8. License ~
*PythonModeLicense*
Python-mode is released under the GNU lesser general public license.
See: http://www.gnu.org/copyleft/lesser.html
If you like this plugin, you can send me a postcard :)
My address is: "Russia, 143401, Krasnogorsk, Shkolnaya 1-19" to "Kirill Klenov".
Thanks for your support!
------------------------------------------------------------------------------
vim:tw=78:ts=8:ft=help:norl: