/
pyref.txt
140 lines (110 loc) · 6.14 KB
/
pyref.txt
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
*pyref.txt* Context-sensitive documentation for Python source code in Vim
===============================================================================
*pyref-contents*
Contents ~
1. Introduction |pyref-introduction|
2. Install & usage |pyref-install-usage|
1. The |g:pyref_mapping| option
2. The |g:pyref_python| option
3. The |g:pyref_django| option
4. The |g:pyref_index| option
5. General note about options |pyref-general-note-about-options|
3. Contact |pyref-contact|
4. License |pyref-license|
===============================================================================
*pyref-introduction*
Introduction ~
The 'pyref.vim' script is a plug-in for the Vim text editor that helps you
look up the documentation for keywords and identifiers from the following
sources using your web browser:
- Python language reference [1]
- Python library reference [2]
- Django documentation [3]
The ':PyRef' command looks up the identifier given as an argument while the
'<F1>' mapping (only available in Python buffers) looks up the item under the
text cursor. The lookup works by scanning through a special index file which
is included in the ZIP archive below, but you can also create/update the index
yourself using the Python script spider.py [4].
===============================================================================
*pyref-install-usage*
Install & usage ~
Unzip the most recent ZIP archive [5] file inside your Vim profile directory
(usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows),
restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
~\vimfiles\doc' instead on Windows). Now try it out: Open a Python script and
press the '<F1>' key on something interesting. If it doesn't work or you want
to change how it works, see the options documented below.
-------------------------------------------------------------------------------
The *g:pyref_mapping* option
If you press '<F1>' and nothing happens you're probably using a terminal that
doesn't pass '<F1>' through to Vim. In this case you can change the key
mapping by setting the global variable |g:pyref_mapping| according to the
syntax expected by Vim's ':imap' and ':nmap' commands:
>
:let g:pyref_mapping = 'K'
Note that setting |g:pyref_mapping| won't change the key mapping in existing
buffers.
-------------------------------------------------------------------------------
The *g:pyref_python* option
This option is useful when you don't always have a reliable internet
connection available while coding. Most Linux distributions have an
installable package containing the Python documentation, for example on Ubuntu
[6] and Debian [7] you can execute the following command to install the
documentation:
>
$ sudo apt-get install python2.6-doc
The above package puts the documentation in '/usr/share/doc/python2.6/html/'
which happens to be the default path checked by the 'pyref.vim' script. If
you've installed the documentation in a different location you can change the
global variable |g:pyref_python|, e.g.:
>
:let g:pyref_python = $HOME . '/docs/python'
-------------------------------------------------------------------------------
The *g:pyref_django* option
This option works like |g:pyref_python| but allows you to configure the path
to your local Django documentation. On Ubuntu [8] and Debian [9] you can
execute the following command to install the Django documentation:
>
$ sudo apt-get install python-django-doc
In this case you shouldn't have to change anything because 'pyref.vim' is
already configured to be compatible with the 'python-django-doc' package.
-------------------------------------------------------------------------------
The *g:pyref_index* option
If you don't like the default location of the index file you can change it by
setting the global variable |g:pyref_index|. A leading '~' in the
|g:pyref_index| variable is expanded to your current home directory ('$HOME'
on UNIX, '%USERPROFILE%' on Windows). Be aware that when you change the
|g:pyref_index| option automatic updates using the |getscript| plug-in won't
update the index file anymore!
-------------------------------------------------------------------------------
*pyref-general-note-about-options*
General note about options ~
You can change the above options permanently by putting the relevant ':let'
statements in your |vimrc| script.
===============================================================================
*pyref-contact*
Contact ~
If you have questions, bug reports, suggestions, etc. the author can be
contacted at peter@peterodding.com. The latest version is available at
http://peterodding.com/code/vim/pyref/ and http://github.com/xolox/vim-pyref.
If you like the script please vote for it on Vim Online [10].
===============================================================================
*pyref-license*
License ~
This software is licensed under the MIT license [11]. Copyright 2013 Peter
Odding <peter@peterodding.com>.
===============================================================================
*pyref-references*
References ~
[1] http://docs.python.org/reference/
[2] http://docs.python.org/library/
[3] http://docs.djangoproject.com/
[4] http://github.com/xolox/vim-pyref/blob/master/spider.py
[5] http://peterodding.com/code/vim/downloads/pyref
[6] http://packages.ubuntu.com/python2.6-doc
[7] http://packages.debian.org/python2.6-doc
[8] http://packages.ubuntu.com/python-django-doc
[9] http://packages.debian.org/python-django-doc
[10] http://www.vim.org/scripts/script.php?script_id=3104
[11] http://en.wikipedia.org/wiki/MIT_License
vim: ft=help