# Python Search

## Element Search

Element searching allows you to place the cursor over just about any element in a source file (method call, class name, constant) and perform a search for that element by issuing the command :PythonSearch. By default this command will search for declarations, but you can specify that you want to search for references using:

    :PythonSearch -x references

If only one result is found and that result is in the current source file, the cursor will be moved to the element found. Otherwise, on single result matches, the value of g:EclimPythonSearchSingleResult will be consulted for the action to take. If there are multiple results, the quickfix list will be opened with the list of results. You can also force the action to use for the current search by suppling the `-a <action>` arg:

    :PythonSearch -x references -a edit

Note

:PythonSearch does not currently support searching for patterns. Attempting to supply a pattern to search for will result in an error.

As a convenience eclim also provides the command :PythonSearchContext. This command accepts only the optional `-a` argument described above, and will perform the appropriate search depending on the context of the element under the cursor.

- If the cursor is on the declaration of a class, function, or method then it will search for all occurrences.
- Otherwise, it will search for the declaration of the element.

## Configuration

Vim Settings

- g:EclimPythonSearchSingleResult (Default: ‘split’) - Determines what action to take when a only a single result is found.

  Possible values include:

  - ‘split’ - open the result in a new window via “split”.
  - ‘edit’ - open the result in the current window.
  - ‘tabnew’ - open the result in a new tab.

  This setting overrides the global default for all supported language types which can be set using the g:EclimDefaultFileOpenAction setting which accepts the same possible values.

- g:EclimQuickFixOpen (Default: ‘botright copen’) Specifies the command used to open the quickfix window when multiple results are found.
- g:EclimQuickFixHeight (Default: 10) - Sets the height, in lines, of the quickfix window when eclim opens it to display search results.