11" -*- vim -*-
22" FILE: python_fn.vim
3- " LAST MODIFICATION: 2008-08 -28 8:19pm
3+ " LAST MODIFICATION: 2017-05 -28 17:47:13
44" (C) Copyright 2001-2005 Mikael Berthe <bmikael@lists.lilotux.net>
55" Maintained by Jon Franklin <jvfranklin@gmail.com>
6- " Version: 1.13
6+ " Modifed by Roman Dobosz <gryf73@gmail.com>
7+ " Version: 1.14
78
89" USAGE:
9- "
10- " See README for installation.
11- " You can set the global variable "g:py_select_leading_comments" to 0
12- " if you don't want to select comments preceding a declaration (these
13- " are usually the description of the function/class).
14- " You can set the global variable "g:py_select_trailing_comments" to 0
15- " if you don't want to select comments at the end of a function/class.
16- " If these variables are not defined, both leading and trailing comments
17- " are selected.
18- " Example: (in your .vimrc) "let g:py_select_leading_comments = 0"
19- " You may want to take a look at the 'shiftwidth' option for the
20- " shift commands...
21- "
22- " REQUIREMENTS:
23- " vim (>= 7)
24- "
25- " Shortcuts:
26- " ]t -- Jump to beginning of block
27- " ]e -- Jump to end of block
28- " ]v -- Select (Visual Line Mode) block
29- " ]< -- Shift block to left
30- " ]> -- Shift block to right
31- " ]# -- Comment selection
32- " ]u -- Uncomment selection
33- " ]c -- Select current/previous class
34- " ]d -- Select current/previous function
35- " ]<up> -- Jump to previous line with the same/lower indentation
36- " ]<down> -- Jump to next line with the same/lower indentation
10+ " See README.rst
3711
12+ " Shortcuts:
3813" Only do this when not done yet for this buffer
3914if exists (" b:loaded_py_ftplugin" )
4015 finish
@@ -46,7 +21,7 @@ vmap ]t :<C-U>PBOB<CR>m'gv``
4621map ]e :PEoB<CR>
4722vmap ]e :<C-U> PEoB<CR> m'gv``
4823
49- map ]v ]tV]e
24+ map vab ]tV]e
5025map ]< ]tV]e<
5126vmap ]< <
5227map ]> ]tV]e>
@@ -57,76 +32,56 @@ vmap ]# :call PythonCommentSelection()<CR>
5732map ]u :call PythonUncommentSelection()<CR>
5833vmap ]u :call PythonUncommentSelection()<CR>
5934
60- map ]c :call PythonSelectObject("class")<CR>
61- map ]d :call PythonSelectObject("function")<CR>
35+ map vac :call PythonSelectObject("class")<CR>
36+ map vaf :call PythonSelectObject("function")<CR>
6237
6338map ]<up> :call PythonNextLine(-1)<CR>
6439map ]<down> :call PythonNextLine(1)<CR>
6540" You may prefer use <s-up> and <s-down>... :-)
6641
6742" jump to previous class
68- map ]J :call PythonDec("class", -1)<CR>
69- vmap ]J :call PythonDec("class", -1)<CR>
43+ map [[ :call PythonDec("class", -1)<CR>
44+ vmap [[ :call PythonDec("class", -1)<CR>
7045
7146" jump to next class
72- map ]j :call PythonDec("class", 1)<CR>
73- vmap ]j :call PythonDec("class", 1)<CR>
47+ map ]] :call PythonDec("class", 1)<CR>
48+ vmap ]] :call PythonDec("class", 1)<CR>
7449
7550" jump to previous function
76- map ]F :call PythonDec("function", -1)<CR>
77- vmap ]F :call PythonDec("function", -1)<CR>
51+ map {{ :call PythonDec("function", -1)<CR>
52+ vmap {{ :call PythonDec("function", -1)<CR>
7853
7954" jump to next function
80- map ]f :call PythonDec("function", 1)<CR>
81- vmap ]f :call PythonDec("function", 1)<CR>
55+ map }} :call PythonDec("function", 1)<CR>
56+ vmap }} :call PythonDec("function", 1)<CR>
8257
8358" Menu entries
84- nmenu <silent> &Python.Update\ IM- Python\ Menu
85- \: call UpdateMenu ()<CR>
59+ nmenu <silent> &Python.Update\ IM- Python\ Menu :call UpdateMenu ()<CR>
8660nmenu &Python.- Sep1- :
87- nmenu <silent> &Python.Beginning\ of\ Block<Tab> [t
88- \] t
89- nmenu <silent> &Python.End\ of\ Block<Tab> ]e
90- \] e
61+ nmenu <silent> &Python.Beginning\ of\ Block<Tab> [t ]t
62+ nmenu <silent> &Python.End\ of\ Block<Tab> ]e ]e
9163nmenu &Python.- Sep2- :
92- nmenu <silent> &Python.Shift\ Block\ Left<Tab> ]<
93- \] <
94- vmenu <silent> &Python.Shift\ Block\ Left<Tab> ]<
95- \] <
96- nmenu <silent> &Python.Shift\ Block\ Right<Tab> ]>
97- \] >
98- vmenu <silent> &Python.Shift\ Block\ Right<Tab> ]>
99- \] >
64+ nmenu <silent> &Python.Shift\ Block\ Left<Tab> ]< ]<
65+ vmenu <silent> &Python.Shift\ Block\ Left<Tab> ]< ]<
66+ nmenu <silent> &Python.Shift\ Block\ Right<Tab> ]> ]>
67+ vmenu <silent> &Python.Shift\ Block\ Right<Tab> ]> ]>
10068nmenu &Python.- Sep3- :
101- vmenu <silent> &Python.Comment \ Selection<Tab> ]#
102- \] #
103- nmenu <silent> &Python.Comment \ Selection<Tab> ]#
104- \] #
105- vmenu <silent> &Python.Uncomment\ Selection<Tab> ]u
106- \] u
107- nmenu <silent> &Python.Uncomment\ Selection<Tab> ]u
108- \] u
69+ vmenu <silent> &Python.Comment \ Selection<Tab> ]# ]#
70+ nmenu <silent> &Python.Comment \ Selection<Tab> ]# ]#
71+ vmenu <silent> &Python.Uncomment\ Selection<Tab> ]u ]u
72+ nmenu <silent> &Python.Uncomment\ Selection<Tab> ]u ]u
10973nmenu &Python.- Sep4- :
110- nmenu <silent> &Python.Previous\ Class<Tab> ]J
111- \] J
112- nmenu <silent> &Python.Next \ Class<Tab> ]j
113- \] j
114- nmenu <silent> &Python.Previous\ Function <Tab> ]F
115- \] F
116- nmenu <silent> &Python.Next \ Function <Tab> ]f
117- \] f
74+ nmenu <silent> &Python.Previous\ Class<Tab> [[ [[
75+ nmenu <silent> &Python.Next \ Class<Tab> ]] ]]
76+ nmenu <silent> &Python.Previous\ Function <Tab> {{ {{
77+ nmenu <silent> &Python.Next \ Function <Tab> }} }}
11878nmenu &Python.- Sep5- :
119- nmenu <silent> &Python.Select\ Block<Tab> ]v
120- \] v
121- nmenu <silent> &Python.Select\ Function <Tab> ]d
122- \] d
123- nmenu <silent> &Python.Select\ Class<Tab> ]c
124- \] c
79+ nmenu <silent> &Python.Select\ Block<Tab> vab vab
80+ nmenu <silent> &Python.Select\ Function <Tab> vaf vaf
81+ nmenu <silent> &Python.Select\ Class<Tab> vac vac
12582nmenu &Python.- Sep6- :
126- nmenu <silent> &Python.Previous\ Line\ wrt\ indent <Tab> ]<up>
127- \] <up>
128- nmenu <silent> &Python.Next \ Line\ wrt\ indent <Tab> ]<down>
129- \] <down>
83+ nmenu <silent> &Python.Previous\ Line\ wrt\ indent <Tab> ]<up> ]<up>
84+ nmenu <silent> &Python.Next \ Line\ wrt\ indent <Tab> ]<down> ]<down>
13085
13186:com ! PBoB execute " normal " .PythonBoB (line (' .' ), -1 , 1 )." G"
13287:com ! PEoB execute " normal " .PythonBoB (line (' .' ), 1 , 1 )." G"
@@ -191,7 +146,7 @@ endfunction
191146" commentString is inserted in non-empty lines, and should be aligned with
192147" the block
193148function ! PythonCommentSelection () range
194- let commentString = " #"
149+ let commentString = " # "
195150 let cl = a: firstline
196151 let ind = 1000 " I hope nobody use so long lines! :)
197152
@@ -225,7 +180,7 @@ endfunction
225180function ! PythonUncommentSelection () range
226181 " commentString could be different than the one from CommentSelection()
227182 " For example, this could be "# \\="
228- let commentString = " #"
183+ let commentString = " # "
229184 let cl = a: firstline
230185 while (cl <= a: lastline )
231186 let ul = substitute (getline (cl ),
0 commit comments