mirror of
https://github.com/gryf/python.vim.git
synced 2025-12-17 11:30:22 +01:00
Version 1.12
* Changed to ftplugin and renamed to avoid collision with vim's ftplugin/python.vim. Patch provided by Christopher Lambacher * Fixed error opening python buffer with no classes or functions. Patch provided by Chris Farrow * Removed duplicate ]f key *Fixed block manipulation bugs due to collision on ]], [[ mappings. See menu for new mappings
This commit is contained in:
committed by
Able Scraper
parent
bf1056d729
commit
6411a284c5
@@ -1,13 +1,17 @@
|
|||||||
" -*- vim -*-
|
" -*- vim -*-
|
||||||
" FILE: python.vim
|
" FILE: python.vim
|
||||||
" LAST MODIFICATION: 2006-11-29 4:09pm
|
" LAST MODIFICATION: 2008-05-17 6:29pm
|
||||||
" (C) Copyright 2001-2005 Mikael Berthe <bmikael@lists.lilotux.net>
|
" (C) Copyright 2001-2005 Mikael Berthe <bmikael@lists.lilotux.net>
|
||||||
" Version: 1.11
|
" Maintained by Jon Franklin <jvfranklin@gmail.com>
|
||||||
|
" Version: 1.12
|
||||||
|
|
||||||
" USAGE:
|
" USAGE:
|
||||||
"
|
"
|
||||||
" Just source this script when editing Python files.
|
" Save this file to $VIMFILES/ftplugin/python.vim. You can have multiple
|
||||||
" Example: au FileType python source ~me/.vim/scripts/python.vim
|
" python ftplugins by creating $VIMFILES/ftplugin/python and saving your
|
||||||
|
" ftplugins in that directory. If saving this to the global ftplugin
|
||||||
|
" directory, this is the recommended method, since vim ships with an
|
||||||
|
" ftplugin/python.vim file already.
|
||||||
" You can set the global variable "g:py_select_leading_comments" to 0
|
" You can set the global variable "g:py_select_leading_comments" to 0
|
||||||
" if you don't want to select comments preceding a declaration (these
|
" if you don't want to select comments preceding a declaration (these
|
||||||
" are usually the description of the function/class).
|
" are usually the description of the function/class).
|
||||||
@@ -23,28 +27,33 @@
|
|||||||
" vim (>= 7)
|
" vim (>= 7)
|
||||||
"
|
"
|
||||||
" Shortcuts:
|
" Shortcuts:
|
||||||
" [[ -- Jump to beginning of block
|
" ]t -- Jump to beginning of block
|
||||||
" ]] -- Jump to end of block
|
" ]e -- Jump to end of block
|
||||||
" ]v -- Select (Visual Line Mode) block
|
" ]v -- Select (Visual Line Mode) block
|
||||||
" ]< -- Shift block to left
|
" ]< -- Shift block to left
|
||||||
" ]> -- Shift block to right
|
" ]> -- Shift block to right
|
||||||
" ]# -- Comment selection
|
" ]# -- Comment selection
|
||||||
" ]u -- Uncomment selection
|
" ]u -- Uncomment selection
|
||||||
" ]c -- Select current/previous class
|
" ]c -- Select current/previous class
|
||||||
" ]f -- Select current/previous function
|
" ]d -- Select current/previous function
|
||||||
" ]<up> -- Jump to previous line with the same/lower indentation
|
" ]<up> -- Jump to previous line with the same/lower indentation
|
||||||
" ]<down> -- Jump to next line with the same/lower indentation
|
" ]<down> -- Jump to next line with the same/lower indentation
|
||||||
|
|
||||||
|
" Only do this when not done yet for this buffer
|
||||||
|
if exists("b:loaded_py_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:loaded_py_ftplugin = 1
|
||||||
|
|
||||||
map [[ :PBoB<CR>
|
map ]t :PBoB<CR>
|
||||||
vmap [[ :<C-U>PBoB<CR>m'gv``
|
vmap ]t :<C-U>PBOB<CR>m'gv``
|
||||||
map ]] :PEoB<CR>
|
map ]e :PEoB<CR>
|
||||||
vmap ]] :<C-U>PEoB<CR>m'gv``
|
vmap ]e :<C-U>PEoB<CR>m'gv``
|
||||||
|
|
||||||
map ]v [[V]]
|
map ]v ]tV]e
|
||||||
map ]< [[V]]<
|
map ]< ]tV]e<
|
||||||
vmap ]< <
|
vmap ]< <
|
||||||
map ]> [[V]]>
|
map ]> ]tV]e>
|
||||||
vmap ]> >
|
vmap ]> >
|
||||||
|
|
||||||
map ]# :call PythonCommentSelection()<CR>
|
map ]# :call PythonCommentSelection()<CR>
|
||||||
@@ -53,7 +62,7 @@ map ]u :call PythonUncommentSelection()<CR>
|
|||||||
vmap ]u :call PythonUncommentSelection()<CR>
|
vmap ]u :call PythonUncommentSelection()<CR>
|
||||||
|
|
||||||
map ]c :call PythonSelectObject("class")<CR>
|
map ]c :call PythonSelectObject("class")<CR>
|
||||||
map ]f :call PythonSelectObject("function")<CR>
|
map ]d :call PythonSelectObject("function")<CR>
|
||||||
|
|
||||||
map ]<up> :call PythonNextLine(-1)<CR>
|
map ]<up> :call PythonNextLine(-1)<CR>
|
||||||
map ]<down> :call PythonNextLine(1)<CR>
|
map ]<down> :call PythonNextLine(1)<CR>
|
||||||
@@ -81,10 +90,10 @@ vmap ]f :call PythonDec("function", 1)<CR>
|
|||||||
nmenu <silent> &Python.Update\ IM-Python\ Menu
|
nmenu <silent> &Python.Update\ IM-Python\ Menu
|
||||||
\:call UpdateMenu()<CR>
|
\:call UpdateMenu()<CR>
|
||||||
nmenu &Python.-Sep1- :
|
nmenu &Python.-Sep1- :
|
||||||
nmenu <silent> &Python.Beginning\ of\ Block<Tab>[[
|
nmenu <silent> &Python.Beginning\ of\ Block<Tab>[t
|
||||||
\[[
|
\]t
|
||||||
nmenu <silent> &Python.End\ of\ Block<Tab>]]
|
nmenu <silent> &Python.End\ of\ Block<Tab>]e
|
||||||
\]]
|
\]e
|
||||||
nmenu &Python.-Sep2- :
|
nmenu &Python.-Sep2- :
|
||||||
nmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
|
nmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
|
||||||
\]<
|
\]<
|
||||||
@@ -115,8 +124,8 @@ nmenu <silent> &Python.Next\ Function<Tab>]f
|
|||||||
nmenu &Python.-Sep5- :
|
nmenu &Python.-Sep5- :
|
||||||
nmenu <silent> &Python.Select\ Block<Tab>]v
|
nmenu <silent> &Python.Select\ Block<Tab>]v
|
||||||
\]v
|
\]v
|
||||||
nmenu <silent> &Python.Select\ Function<Tab>]f
|
nmenu <silent> &Python.Select\ Function<Tab>]d
|
||||||
\]f
|
\]d
|
||||||
nmenu <silent> &Python.Select\ Class<Tab>]c
|
nmenu <silent> &Python.Select\ Class<Tab>]c
|
||||||
\]c
|
\]c
|
||||||
nmenu &Python.-Sep6- :
|
nmenu &Python.-Sep6- :
|
||||||
@@ -125,7 +134,6 @@ nmenu <silent> &Python.Previous\ Line\ wrt\ indent<Tab>]<up>
|
|||||||
nmenu <silent> &Python.Next\ Line\ wrt\ indent<Tab>]<down>
|
nmenu <silent> &Python.Next\ Line\ wrt\ indent<Tab>]<down>
|
||||||
\]<down>
|
\]<down>
|
||||||
|
|
||||||
|
|
||||||
:com! PBoB execute "normal ".PythonBoB(line('.'), -1, 1)."G"
|
:com! PBoB execute "normal ".PythonBoB(line('.'), -1, 1)."G"
|
||||||
:com! PEoB execute "normal ".PythonBoB(line('.'), 1, 1)."G"
|
:com! PEoB execute "normal ".PythonBoB(line('.'), 1, 1)."G"
|
||||||
:com! UpdateMenu call UpdateMenu()
|
:com! UpdateMenu call UpdateMenu()
|
||||||
@@ -309,8 +317,6 @@ function! UpdateMenu()
|
|||||||
" all buffers currently open, and group classes and functions by buffer
|
" all buffers currently open, and group classes and functions by buffer
|
||||||
if exists("g:menuran")
|
if exists("g:menuran")
|
||||||
aunmenu IM-Python
|
aunmenu IM-Python
|
||||||
else
|
|
||||||
let g:menuran=1
|
|
||||||
endif
|
endif
|
||||||
let restore_fe = &foldenable
|
let restore_fe = &foldenable
|
||||||
set nofoldenable
|
set nofoldenable
|
||||||
@@ -349,6 +355,8 @@ function! MenuBuilder()
|
|||||||
else " this is a function
|
else " this is a function
|
||||||
call AddFunction(objname, linenum, parentclass)
|
call AddFunction(objname, linenum, parentclass)
|
||||||
endif
|
endif
|
||||||
|
" We actually created a menu, so lets set the global variable
|
||||||
|
let g:menuran=1
|
||||||
call RebuildClassList(classlist, [objname, indentcol], classordef)
|
call RebuildClassList(classlist, [objname, indentcol], classordef)
|
||||||
endif " line matched
|
endif " line matched
|
||||||
norm j
|
norm j
|
||||||
Reference in New Issue
Block a user