Permalink
Browse files

Removed forced default keybinding but added command for easy mapping.

Updated help file accordingly.
  • Loading branch information...
1 parent d91657c commit 93b76d5b184535e4f294c063950746f13e141f72 @actionshrimp committed Jun 19, 2011
Showing with 16 additions and 35 deletions.
  1. +14 −23 doc/xpath.txt
  2. +2 −12 plugin/xpath.vim
View
37 doc/xpath.txt
@@ -10,7 +10,7 @@ This plugin adds XPath search functionality to Vim.
INSTALLATION *xpath-installation*
To install the plugin, extract the directory structure into your vimfiles, or
-source the |vimball|.
+use the excellent Pathogen plugin.
For the plugin to run, you'll need python support enabled. You can check this
with |:version|, and looking for +python.
@@ -22,15 +22,19 @@ Without these the plugin will let you know on startup, then stop loading.
==============================================================================
USAGE *xpath-usage*
-When you open a file which the plugin recognises (by default: xml, xslt - to
-define additional filetypes see |xpath-configure|), the mapping X in normal
-mode will launch an XPath search prompt. Type your xpath in here, then hit
-<Enter> to open a new results window.
+XPath search defines several functions, but the main interface to the plugin
+is through the XPathSearchPrompt command, which launches the search input
+prompt.
+
+You may want to map the command to a key - this will map F5 to call the command:
-The search prompt supports context-sensitive tab completion. To tab complete
-attributes in the current context, type an @ sign at the beginning of the
-current context (e.g. //Parent/Child/@<Tab> will complete all attributes
-for Child).
+noremap <F5> XPathSearchPrompt
+
+The search prompt appears, and supports context-sensitive tab completion. By
+default hitting tab will autocomplete a tag that would be available in the
+current XPath context. To tab complete attributes in the current context, type
+an @ sign at the beginning of the current context (e.g. //Parent/Child/@<Tab>
+will complete all attributes for Child).
When you do a search, the cursor will jump to the first result in the results
window. If the result has a line number, you can also press <Enter> on the
@@ -41,11 +45,7 @@ If the XML file is not valid, the plugin will let you know of any XML
validation errors. Again if there is a line number associated with the error
you can hit <Enter> to jump there.
-Pressing X in normal mode on the results window will cause it to close again.
-
-XPath search defines several functions, but the main interface to the plugin
-is through the XPathSearchPrompt() function, which launches the search input
-prompt.
+Pressing q in normal mode on the results window will cause it to close again.
==============================================================================
CONFIGURATION *xpath-configure*
@@ -54,12 +54,3 @@ To disable the plugin for certain situtations, add the following in your
.vimrc:
let g:loaded_xpath = 1
-
-To add additional filetypes to add the normal mode X mapping to, append a list
-of the filetypes to the g:xpath_search_filetypes variable. For example, to
-enable the plugin for htm and html files, you can use the following:
-
-let g:xpath_search_filetypes += ['htm', 'html']
-
-To display the filetype for a file you currently have open in order to set up
-a new match, you can use the command :set filetype.
View
14 plugin/xpath.vim
@@ -8,8 +8,6 @@ if exists("g:loaded_xpath")
endif
let g:loaded_xpath = 1
-let g:xpath_search_filetypes = ['xml', 'xslt']
-
if !(has("python"))
echoerr "XPath plugin not loaded due to no python support."
finish
@@ -31,15 +29,7 @@ endif
let s:results_buffer_name = 'xpath_search_results'
let s:result_pattern = '^|\(\d\+\).*$'
-autocmd FileType * :call XPathFileType(expand("<amatch>"))
-
-function! XPathFileType(bufft)
- for ft in g:xpath_search_filetypes
- if (a:bufft == ft)
- nnoremap <buffer> X :call XPathSearchPrompt()<cr>
- end
- endfor
-endfunction
+command XPathSearchPrompt :call XPathSearchPrompt()
function! XPathSearchPrompt()
@@ -149,7 +139,7 @@ function! SetupXPathResultsBuffer(search_buffer)
"current window is the results window
setlocal buftype=nofile bufhidden=hide noswapfile syntax=xpathresults nowrap wfh
- nmap <buffer> <silent> X :q<cr>
+ nmap <buffer> <silent> q :q<cr>
autocmd CursorMoved <buffer> :call XPathResultsCursorlineCheck()
autocmd VimResized <buffer> :py xpath_interface.window_resized()

0 comments on commit 93b76d5

Please sign in to comment.