Pacifying Vimmers
Perhaps most usefully, Vimple provides a few maps and commands to make the casual vimmer’s life a little easier. If you don’t want any of these maps and commands, they can be disabled by adding this line to your $MYVIMRC:
let g:init_vimple_maps_and_commands = 0
Here are a few examples of such maps and commands:
Shows spelling suggestions in an overlay window. Pressing <enter>
will replace the word under the cursor in the original window with the
current word under the cursor in the overlay.
Use <plug>vimple_spell_suggest
if you want to map this behaviour
to a differnt key.
Shows identifier search results in an overlay window. Pressing <enter>
will jump to the associated line of the identifier under the cursor.
Use <plug>vimple_ident_search
if you want to map this behaviour
to a differnt key.
Shows tag search results in an overlay window. Pressing <enter>
will jump to the associated line of the tag under the cursor.
Use <plug>vimple_tag_search
if you want to map this behaviour
to a differnt key.
A function which calls script-local function
in script
with arguments arg
. This lets you call <SNR>
/ s:
functions by script name rather than SNR (script-number).
Performs the series of bar-separated ex-commands over the buffers in the QuickFix list.
Note
|
The location-list analogue is :LLdo
|
Performs the series of bar-separated ex-commands over the buffers of the given type.
Performs the series of bar-separated ex-commands over the buffers with names matching pattern.
Saves the output of ex-command
into the specified register
or variable.
Saves the output of ex-command
into the specified register
or variable and returns the output for further use in
expressions.
Uses pattern
in a :global /pattern/
command and returns
the results as a list of lines.
:echo GCollect('^\s*===\s*')
Uses pattern
in a :global /pattern/
command and returns
the results as a list of lines with the pattern
stripped.
:echo GCCollect('^\s*===\s*')
Shows your currently active |:map|s and |:imap|s in a new buffer. :MyMaps attempts to group related maps to more easily allow you to create a custom map layout for your various |'filetype'|s.
The Scope() function attempts to show the current function or
class/method scope. Some people like to display this information in
their statusline
, like:
set statusline=%f%m%r%h%w\ [%n:%{&ff}/%Y]\%{Scope()}%=[0x\%04.4B][%03v][%p%%\ line\ %l\ of\ %L]
Currently only Vim & Python (and Python only for testing purposes, created by a NON Pythonista — patches welcome) have been implemented, but it is very easy for you to write scope functions for your own filetypes. Take Ruby for example: Create ~/.vim/ftplugin/ruby_scope.vim
like this:
function! Scope_ruby() let class_scope = scope#inspect('^\s*class\s\+\([a-zA-Z0-9_.]\+\)', '^\s*end') let method_scope = scope#inspect('^\s*def\s\+\([a-zA-Z0-9_.]\+\)', '^\s*end') return ' ' . join(map(class_scope.stack, 'v:val.head_line_number . "," . v:val.tail_line_number . " " . v:val.head_string'), ' :: ') \. ' >> ' . join(map(method_scope.stack, 'v:val.head_line_number . "," . v:val.tail_line_number . " " . v:val.head_string'), ' > ') endfunction
Note
|
The above example for Ruby is woefully inadequate. A better effect
might be achievable with more context in the regex patterns. The
patterns in syntax/ruby.vim might be useful. Parsing with regex is futile.
|
By default, jj
in insert mode activates a user-extendible
meta-completion list. The default list includes abbreviations (if you
have https://github.com/dahu/Aboriginal), some date-time patterns and
the built-in dictionary completion (<c-x><c-k>
).
The default jj
can be overridden like this:
imap <c-x><c-c> <plug>vimple_completers_trigger
Two other example shortcuts provided by vimple by default:
-
<c-x><c-a>
to complete abbreviations -
<c-x><c-z>
to complete datetimes
These defaults can be disabled by adding these lines to your $MYVIMRC:
imap <unique> <nop-1> <plug>vimple_completers_trigger imap <unique> <nop-2> <plug>vimple_completers_abbrev_trigger imap <unique> <nop-3> <plug>vimple_completers_datetime_trigger
Note
|
<unique> is used here to trigger a warning if you’re re-using a <nop- n > map.
|
Vimple also provides VimLOO (Object Oriented VimL) objects for these read-only :ex commands:
-
:ls — vimple#bl
-
:scriptnames — vimple#sn
-
:highlight — vimple#hl
-
:version — vimple#vn
-
:marks — vimple#ma
-
:undolist — vimple#ul
-
:maps — vimple#mp
Note
|
The awesome plugin
buffalo uses the
vimple#bl object.
|
In addition to these existing :ex wrappers, Vimple allows developers to craft their own objects too. See autoload/vimple/*.vim for examples.