aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/CMakeLists.txt2
-rw-r--r--runtime/autoload/health.vim35
-rw-r--r--runtime/autoload/provider/clipboard.vim7
-rw-r--r--runtime/autoload/provider/ruby.vim50
-rw-r--r--runtime/autoload/provider/script_host.rb8
-rw-r--r--runtime/autoload/remote/host.vim2
-rw-r--r--runtime/doc/eval.txt175
-rw-r--r--runtime/doc/gui.txt4
-rw-r--r--runtime/doc/if_ruby.txt185
-rw-r--r--runtime/doc/map.txt12
-rw-r--r--runtime/doc/nvim.txt9
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt22
-rw-r--r--runtime/doc/provider.txt19
-rw-r--r--runtime/doc/starting.txt41
-rw-r--r--runtime/doc/various.txt2
-rw-r--r--runtime/doc/vim_diff.txt5
-rw-r--r--runtime/macros/justify.vim319
-rw-r--r--runtime/macros/shellmenu.vim97
-rw-r--r--runtime/macros/swapmous.vim25
-rw-r--r--runtime/pack/dist/opt/justify/plugin/justify.vim316
-rw-r--r--runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim94
-rw-r--r--runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim22
-rw-r--r--runtime/plugin/matchit.vim30
23 files changed, 964 insertions, 517 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 66971eccb2..0dd8b07b7a 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -124,7 +124,7 @@ endforeach()
file(GLOB_RECURSE RUNTIME_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- *.vim *.dict *.py *.ps *.tutor)
+ *.vim *.dict *.py *.rb *.ps *.tutor)
foreach(F ${RUNTIME_FILES})
get_filename_component(BASEDIR ${F} PATH)
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index dc362577a6..0a698e6492 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -404,6 +404,39 @@ function! s:diagnose_python(version) abort
endfunction
+function! s:diagnose_ruby() abort
+ echo 'Checking: Ruby'
+ let ruby_vers = systemlist('ruby -v')[0]
+ let ruby_prog = provider#ruby#Detect()
+ let notes = []
+
+ if empty(ruby_prog)
+ let ruby_prog = 'not found'
+ let prog_vers = 'not found'
+ call add(notes, 'Suggestion: Install the neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ else
+ silent let prog_vers = systemlist(ruby_prog . ' --version')[0]
+
+ if v:shell_error
+ let prog_vers = 'outdated'
+ call add(notes, 'Suggestion: Install the latest neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ elseif s:version_cmp(prog_vers, "0.2.0") == -1
+ let prog_vers .= ' (outdated)'
+ call add(notes, 'Suggestion: Install the latest neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ endif
+ endif
+
+ echo ' Ruby Version: ' . ruby_vers
+ echo ' Host Executable: ' . ruby_prog
+ echo ' Host Version: ' . prog_vers
+
+ call s:echo_notes(notes)
+endfunction
+
+
function! health#check(bang) abort
redir => report
try
@@ -411,6 +444,8 @@ function! health#check(bang) abort
silent echo ''
silent call s:diagnose_python(3)
silent echo ''
+ silent call s:diagnose_ruby()
+ silent echo ''
silent call s:diagnose_manifest()
silent echo ''
finally
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 77bc8c781d..0f4aa78ddd 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -65,11 +65,10 @@ endif
let s:clipboard = {}
function! s:clipboard.get(reg)
- let reg = a:reg == '"' ? '+' : a:reg
- if s:selections[reg].owner > 0
- return s:selections[reg].data
+ if s:selections[a:reg].owner > 0
+ return s:selections[a:reg].data
end
- return s:try_cmd(s:paste[reg])
+ return s:try_cmd(s:paste[a:reg])
endfunction
function! s:clipboard.set(lines, regtype, reg)
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
index aad8c09d28..e9130b98c1 100644
--- a/runtime/autoload/provider/ruby.vim
+++ b/runtime/autoload/provider/ruby.vim
@@ -1,12 +1,18 @@
" The Ruby provider helper
-if exists('s:loaded_ruby_provider')
+if exists('g:loaded_ruby_provider')
finish
endif
+let g:loaded_ruby_provider = 1
-let s:loaded_ruby_provider = 1
+function! provider#ruby#Detect() abort
+ return exepath('neovim-ruby-host')
+endfunction
+
+function! provider#ruby#Prog()
+ return s:prog
+endfunction
function! provider#ruby#Require(host) abort
- " Collect registered Ruby plugins into args
let args = []
let ruby_plugins = remote#host#PluginsForHost(a:host.name)
@@ -16,19 +22,43 @@ function! provider#ruby#Require(host) abort
try
let channel_id = rpcstart(provider#ruby#Prog(), args)
-
- if rpcrequest(channel_id, 'poll') == 'ok'
+ if rpcrequest(channel_id, 'poll') ==# 'ok'
return channel_id
endif
catch
echomsg v:throwpoint
echomsg v:exception
endtry
-
- throw remote#host#LoadErrorForHost(a:host.orig_name,
- \ '$NVIM_RUBY_LOG_FILE')
+ throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_RUBY_LOG_FILE')
endfunction
-function! provider#ruby#Prog() abort
- return 'neovim-ruby-host'
+function! provider#ruby#Call(method, args)
+ if s:err != ''
+ echoerr s:err
+ return
+ endif
+
+ if !exists('s:host')
+ try
+ let s:host = remote#host#Require('legacy-ruby-provider')
+ catch
+ let s:err = v:exception
+ echohl WarningMsg
+ echomsg v:exception
+ echohl None
+ return
+ endtry
+ endif
+ return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host))
endfunction
+
+let s:err = ''
+let s:prog = provider#ruby#Detect()
+let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb'
+
+if empty(s:prog)
+ let s:err = 'Cannot find the neovim RubyGem. Try :CheckHealth'
+endif
+
+call remote#host#RegisterClone('legacy-ruby-provider', 'ruby')
+call remote#host#RegisterPlugin('legacy-ruby-provider', s:plugin_path, [])
diff --git a/runtime/autoload/provider/script_host.rb b/runtime/autoload/provider/script_host.rb
new file mode 100644
index 0000000000..1dade766c7
--- /dev/null
+++ b/runtime/autoload/provider/script_host.rb
@@ -0,0 +1,8 @@
+begin
+ require "neovim/ruby_provider"
+rescue LoadError
+ warn(
+ "Your neovim RubyGem is missing or out of date. " +
+ "Install the latest version using `gem install neovim`."
+ )
+end
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index 4ec2eeb5b7..eb5e87d7e1 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -121,7 +121,7 @@ endfunction
function! s:GetManifest() abort
let prefix = exists('$MYVIMRC')
\ ? $MYVIMRC
- \ : matchstr(get(split(capture('scriptnames'), '\n'), 0, ''), '\f\+$')
+ \ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
return fnamemodify(expand(prefix, 1), ':h')
\.'/.'.fnamemodify(prefix, ':t').'-rplugin~'
endfunction
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 0ca41370e9..3fa5474a7e 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2016 Apr 12
+*eval.txt* For Vim version 7.4. Last change: 2016 Mar 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -103,18 +103,9 @@ to Float, printf() for Float to String and float2nr() for Float to Number.
*E891* *E892* *E893* *E894*
When expecting a Float a Number can also be used, but nothing else.
- *E706* *sticky-type-checking*
-You will get an error if you try to change the type of a variable. You need
-to |:unlet| it first to avoid this error. String and Number are considered
-equivalent though, as well are Float and Number. Consider this sequence of
-commands: >
- :let l = "string"
- :let l = 44 " changes type from String to Number
- :let l = [1, 2, 3] " error! l is still a Number
- :let l = 4.4 " changes type from Number to Float
- :let l = "string" " error!
-
-
+ *no-type-checking*
+You will not get an error if you try to change the type of a variable.
+
1.2 Function references ~
*Funcref* *E695* *E718*
A Funcref variable is obtained with the |function()| function. It can be used
@@ -763,13 +754,23 @@ expressions are referring to the same |List| or |Dictionary| instance. A copy
of a |List| is different from the original |List|. When using "is" without
a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot"
equivalent to using "not equal". Except that a different type means the
-values are different: "4 == '4'" is true, "4 is '4'" is false and "0 is []" is
-false and not an error. "is#"/"isnot#" and "is?"/"isnot?" can be used to match
-and ignore case.
+values are different: >
+ echo 4 == '4'
+ 1
+ echo 4 is '4'
+ 0
+ echo 0 is []
+ 0
+"is#"/"isnot#" and "is?"/"isnot?" can be used to match and ignore case.
When comparing a String with a Number, the String is converted to a Number,
-and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE,
-because 'x' converted to a Number is zero.
+and the comparison is done on Numbers. This means that: >
+ echo 0 == 'x'
+ 1
+because 'x' converted to a Number is zero. However: >
+ echo 0 == 'x'
+ 0
+Inside a List or Dictionary this conversion is not used.
When comparing two Strings, this is done with strcmp() or stricmp(). This
results in the mathematical difference (comparing byte values), not
@@ -1793,10 +1794,13 @@ argidx() Number current index in the argument list
arglistid([{winnr} [, {tabnr}]]) Number argument list id
argv({nr}) String {nr} entry of the argument list
argv() List the argument list
-assert_equal({exp}, {act} [, {msg}]) none assert {exp} equals {act}
+assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act}
assert_exception( {error} [, {msg}]) none assert {error} is in v:exception
assert_fails( {cmd} [, {error}]) none assert {cmd} fails
assert_false({actual} [, {msg}]) none assert {actual} is false
+assert_match( {pat}, {text} [, {msg}]) none assert {pat} matches {text}
+assert_notequal( {exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
+assert_notmatch( {pat}, {text} [, {msg}]) none assert {pat} not matches {text}
assert_true({actual} [, {msg}]) none assert {actual} is true
asin({expr}) Float arc sine of {expr}
atan({expr}) Float arc tangent of {expr}
@@ -1815,7 +1819,6 @@ byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr}
byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr}
call({func}, {arglist} [, {dict}])
any call {func} with arguments {arglist}
-capture({command}) String capture output of {command}
ceil({expr}) Float round {expr} up
changenr() Number current change number
char2nr({expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
@@ -1851,6 +1854,7 @@ escape({string}, {chars}) String escape {chars} in {string} with '\'
eval({string}) any evaluate {string} into its value
eventhandler() Number TRUE if inside an event handler
executable({expr}) Number 1 if executable {expr} exists
+execute({command}) String execute and capture output of {command}
exepath({expr}) String full path of the command {expr}
exists({expr}) Number TRUE if {expr} exists
extend({expr1}, {expr2} [, {expr3}])
@@ -1893,6 +1897,7 @@ getcmdline() String return the current command-line
getcmdpos() Number return cursor position in command-line
getcmdtype() String return current command-line type
getcmdwintype() String return current command-line window type
+getcompletion({pat}, {type}) List list of cmdline completion matches
getcurpos() List position of the cursor
getcwd([{winnr} [, {tabnr}]]) String the current working directory
getfontname([{name}]) String name of font being used
@@ -2143,6 +2148,10 @@ values({dict}) List values in {dict}
virtcol({expr}) Number screen column of cursor or mark
visualmode([expr]) String last visual mode used
wildmenumode() Number whether 'wildmenu' mode is active
+win_getid( [{win} [, {tab}]]) Number get window ID for {win} in {tab}
+win_gotoid( {expr}) Number go to window with ID {expr}
+win_id2tabwin( {expr}) List get tab window nr from window ID
+win_id2win( {expr}) Number get window nr from window ID
winbufnr({nr}) Number buffer number of window {nr}
wincol() Number window column of the cursor
winheight({nr}) Number height of window {nr}
@@ -2290,6 +2299,36 @@ assert_false({actual} [, {msg}]) *assert_false()*
When {msg} is omitted an error in the form "Expected False but
got {actual}" is produced.
+ *assert_match()*
+assert_match({pattern}, {actual} [, {msg}])
+ When {pattern} does not match {actual} an error message is
+ added to |v:errors|.
+
+ {pattern} is used as with |=~|: The matching is always done
+ like 'magic' was set and 'cpoptions' is empty, no matter what
+ the actual value of 'magic' or 'cpoptions' is.
+
+ {actual} is used as a string, automatic conversion applies.
+ Use "^" and "$" to match with the start and end of the text.
+ Use both to match the whole text.
+
+ When {msg} is omitted an error in the form "Pattern {pattern}
+ does not match {actual}" is produced.
+ Example: >
+ assert_match('^f.*o$', 'foobar')
+< Will result in a string to be added to |v:errors|:
+ test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
+
+ *assert_notequal()*
+assert_notequal({expected}, {actual} [, {msg}])
+ The opposite of `assert_equal()`: add an error message to
+ |v:errors| when {expected} and {actual} are equal.
+
+ *assert_notmatch()*
+assert_notmatch({pattern}, {actual} [, {msg}])
+ The opposite of `assert_match()`: add an error message to
+ |v:errors| when {pattern} matches {actual}.
+
assert_true({actual} [, {msg}]) *assert_true()*
When {actual} is not true an error message is added to
|v:errors|, like with |assert_equal()|.
@@ -2500,21 +2539,6 @@ call({func}, {arglist} [, {dict}]) *call()* *E699*
{dict} is for functions with the "dict" attribute. It will be
used to set the local variable "self". |Dictionary-function|
-capture({command}) *capture()*
- Capture output of {command}.
- If {command} is a |String|, returns {command} output.
- If {command} is a |List|, returns concatenated outputs.
- Examples: >
- echo capture('echon "foo"')
-< foo >
- echo capture(['echon "foo"', 'echon "bar"'])
-< foobar
- This function is not available in the |sandbox|.
- Note: {command} executes as if prepended with |:silent|
- (output is collected, but not displayed). If nested, an outer
- capture() will not observe the output of inner calls.
- Note: Text attributes (highlights) are not captured.
-
ceil({expr}) *ceil()*
Return the smallest integral value greater than or equal to
{expr} as a |Float| (round up).
@@ -2965,6 +2989,21 @@ executable({expr}) *executable()*
0 does not exist
-1 not implemented on this system
+execute({command}) *execute()*
+ Execute {command} and capture its output.
+ If {command} is a |String|, returns {command} output.
+ If {command} is a |List|, returns concatenated outputs.
+ Examples: >
+ echo execute('echon "foo"')
+< foo >
+ echo execute(['echon "foo"', 'echon "bar"'])
+< foobar
+ This function is not available in the |sandbox|.
+ Note: {command} executes as if prepended with |:silent|
+ (output is collected but not displayed). If nested, an outer
+ execute() will not observe output of the inner calls.
+ Note: Text attributes (highlights) are not captured.
+
exepath({expr}) *exepath()*
If {expr} is an executable and is either an absolute path, a
relative path or found in $PATH, return the full path.
@@ -3623,6 +3662,49 @@ getcmdwintype() *getcmdwintype()*
values are the same as |getcmdtype()|. Returns an empty string
when not in the command-line window.
+getcompletion({pat}, {type}) *getcompletion()*
+ Return a list of command-line completion matches. {type}
+ specifies what for. The following completion types are
+ supported:
+
+ augroup autocmd groups
+ buffer buffer names
+ behave :behave suboptions
+ color color schemes
+ command Ex command (and arguments)
+ compiler compilers
+ cscope |:cscope| suboptions
+ dir directory names
+ environment environment variable names
+ event autocommand events
+ expression Vim expression
+ file file and directory names
+ file_in_path file and directory names in |'path'|
+ filetype filetype names |'filetype'|
+ function function name
+ help help subjects
+ highlight highlight groups
+ history :history suboptions
+ locale locale names (as output of locale -a)
+ mapping mapping name
+ menu menus
+ option options
+ shellcmd Shell command
+ sign |:sign| suboptions
+ syntax syntax file names |'syntax'|
+ syntime |:syntime| suboptions
+ tag tags
+ tag_listfiles tags, file names
+ user user names
+ var user variables
+
+ If {pat} is an empty string, then all the matches are returned.
+ Otherwise only items matching {pat} are returned. See
+ |wildcards| for the use of special characters in {pat}.
+
+ If there are no matches, an empty list is returned. An
+ invalid value for {type} produces an error.
+
*getcurpos()*
getcurpos() Get the position of the cursor. This is like getpos('.'), but
includes an extra item in the list:
@@ -7124,6 +7206,29 @@ wildmenumode() *wildmenumode()*
(Note, this needs the 'wildcharm' option set appropriately).
+win_getid([{win} [, {tab}]]) *win_getid()*
+ Get the window ID for the specified window.
+ When {win} is missing use the current window.
+ With {win} this is the window number. The top window has
+ number 1.
+ Without {tab} use the current tab, otherwise the tab with
+ number {tab}. The first tab has number one.
+ Return zero if the window cannot be found.
+
+win_gotoid({expr}) *win_gotoid()*
+ Go to window with ID {expr}. This may also change the current
+ tabpage.
+ Return 1 if successful, 0 if the window cannot be found.
+
+win_id2tabwin({expr} *win_id2tabwin()*
+ Return a list with the tab number and window number of window
+ with ID {expr}: [tabnr, winnr].
+ Return [0, 0] if the window cannot be found.
+
+win_id2win({expr}) *win_id2win()*
+ Return the window number of window with ID {expr}.
+ Return 0 if the window cannot be found in the current tabpage.
+
*winbufnr()*
winbufnr({nr}) The result is a Number, which is the number of the buffer
associated with window {nr}. When {nr} is zero, the number of
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index e2fb501ac5..1e8bb408d9 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -825,13 +825,13 @@ the <CR> key. |<>|)
See section |42.4| in the user manual.
- *:tmenu* *:tm*
+ *:tmenu*
:tm[enu] {menupath} {rhs} Define a tip for a menu or tool. {only in
X11 and Win32 GUI}
:tm[enu] [menupath] List menu tips. {only in X11 and Win32 GUI}
- *:tunmenu* *:tu*
+ *:tunmenu*
:tu[nmenu] {menupath} Remove a tip for a menu or tool.
{only in X11 and Win32 GUI}
diff --git a/runtime/doc/if_ruby.txt b/runtime/doc/if_ruby.txt
new file mode 100644
index 0000000000..fdd63501ea
--- /dev/null
+++ b/runtime/doc/if_ruby.txt
@@ -0,0 +1,185 @@
+*if_ruby.txt*
+
+
+ VIM REFERENCE MANUAL by Shugo Maeda
+
+The Ruby Interface to Vim *ruby* *Ruby*
+
+
+1. Commands |ruby-commands|
+2. The VIM module |ruby-vim|
+3. VIM::Buffer objects |ruby-buffer|
+4. VIM::Window objects |ruby-window|
+5. Global variables |ruby-globals|
+
+ *E266* *E267* *E268* *E269* *E270* *E271* *E272* *E273*
+
+The home page for ruby is http://www.ruby-lang.org/. You can find links for
+downloading Ruby there.
+
+==============================================================================
+1. Commands *ruby-commands*
+
+ *:ruby* *:rub*
+:rub[y] {cmd} Execute Ruby command {cmd}. A command to try it out: >
+ :ruby print "Hello"
+
+:rub[y] << {endpattern}
+{script}
+{endpattern}
+ Execute Ruby script {script}.
+ {endpattern} must NOT be preceded by any white space.
+ If {endpattern} is omitted, it defaults to a dot '.'
+ like for the |:append| and |:insert| commands. This
+ form of the |:ruby| command is mainly useful for
+ including ruby code in vim scripts.
+ Note: This command doesn't work when the Ruby feature
+ wasn't compiled in. To avoid errors, see
+ |script-here|.
+
+Example Vim script: >
+
+ function! RedGem()
+ ruby << EOF
+ class Garnet
+ def initialize(s)
+ @buffer = VIM::Buffer.current
+ vimputs(s)
+ end
+ def vimputs(s)
+ @buffer.append(@buffer.count,s)
+ end
+ end
+ gem = Garnet.new("pretty")
+ EOF
+ endfunction
+<
+
+ *:rubydo* *:rubyd* *E265*
+:[range]rubyd[o] {cmd} Evaluate Ruby command {cmd} for each line in the
+ [range], with $_ being set to the text of each line in
+ turn, without a trailing <EOL>. Setting $_ will change
+ the text, but note that it is not possible to add or
+ delete lines using this command.
+ The default for [range] is the whole file: "1,$".
+
+ *:rubyfile* *:rubyf*
+:rubyf[ile] {file} Execute the Ruby script in {file}. This is the same as
+ ":ruby load 'file'", but allows file name completion.
+
+Executing Ruby commands is not possible in the |sandbox|.
+
+==============================================================================
+2. The VIM module *ruby-vim*
+
+Ruby code gets all of its access to vim via the "VIM" module.
+
+Overview >
+ print "Hello" # displays a message
+ VIM.command(cmd) # execute an Ex command
+ num = VIM::Window.count # gets the number of windows
+ w = VIM::Window[n] # gets window "n"
+ cw = VIM::Window.current # gets the current window
+ num = VIM::Buffer.count # gets the number of buffers
+ b = VIM::Buffer[n] # gets buffer "n"
+ cb = VIM::Buffer.current # gets the current buffer
+ w.height = lines # sets the window height
+ w.cursor = [row, col] # sets the window cursor position
+ pos = w.cursor # gets an array [row, col]
+ name = b.name # gets the buffer file name
+ line = b[n] # gets a line from the buffer
+ num = b.count # gets the number of lines
+ b[n] = str # sets a line in the buffer
+ b.delete(n) # deletes a line
+ b.append(n, str) # appends a line after n
+ line = VIM::Buffer.current.line # gets the current line
+ num = VIM::Buffer.current.line_number # gets the current line number
+ VIM::Buffer.current.line = "test" # sets the current line number
+<
+
+Module Functions:
+
+ *ruby-message*
+VIM::message({msg})
+ Displays the message {msg}.
+
+ *ruby-set_option*
+VIM::set_option({arg})
+ Sets a vim option. {arg} can be any argument that the ":set" command
+ accepts. Note that this means that no spaces are allowed in the
+ argument! See |:set|.
+
+ *ruby-command*
+VIM::command({cmd})
+ Executes Ex command {cmd}.
+
+ *ruby-evaluate*
+VIM::evaluate({expr})
+ Evaluates {expr} using the vim internal expression evaluator (see
+ |expression|). Returns the expression result as a string.
+ A |List| is turned into a string by joining the items and inserting
+ line breaks.
+
+==============================================================================
+3. VIM::Buffer objects *ruby-buffer*
+
+VIM::Buffer objects represent vim buffers.
+
+Class Methods:
+
+current Returns the current buffer object.
+count Returns the number of buffers.
+self[{n}] Returns the buffer object for the number {n}. The first number
+ is 0.
+
+Methods:
+
+name Returns the name of the buffer.
+number Returns the number of the buffer.
+count Returns the number of lines.
+length Returns the number of lines.
+self[{n}] Returns a line from the buffer. {n} is the line number.
+self[{n}] = {str}
+ Sets a line in the buffer. {n} is the line number.
+delete({n}) Deletes a line from the buffer. {n} is the line number.
+append({n}, {str})
+ Appends a line after the line {n}.
+line Returns the current line of the buffer if the buffer is
+ active.
+line = {str} Sets the current line of the buffer if the buffer is active.
+line_number Returns the number of the current line if the buffer is
+ active.
+
+==============================================================================
+4. VIM::Window objects *ruby-window*
+
+VIM::Window objects represent vim windows.
+
+Class Methods:
+
+current Returns the current window object.
+count Returns the number of windows.
+self[{n}] Returns the window object for the number {n}. The first number
+ is 0.
+
+Methods:
+
+buffer Returns the buffer displayed in the window.
+height Returns the height of the window.
+height = {n} Sets the window height to {n}.
+width Returns the width of the window.
+width = {n} Sets the window width to {n}.
+cursor Returns a [row, col] array for the cursor position.
+cursor = [{row}, {col}]
+ Sets the cursor position to {row} and {col}.
+
+==============================================================================
+5. Global variables *ruby-globals*
+
+There are two global variables.
+
+$curwin The current window object.
+$curbuf The current buffer object.
+
+==============================================================================
+ vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 31c3198f72..c1eef398e2 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -55,6 +55,7 @@ modes.
:im[ap] {lhs} {rhs} |mapmode-i| *:im* *:imap*
:lm[ap] {lhs} {rhs} |mapmode-l| *:lm* *:lmap*
:cm[ap] {lhs} {rhs} |mapmode-c| *:cm* *:cmap*
+:tm[ap] {lhs} {rhs} |mapmode-t| *:tm* *:tmap*
Map the key sequence {lhs} to {rhs} for the modes
where the map command applies. The result, including
{rhs}, is then further scanned for mappings. This
@@ -71,6 +72,7 @@ modes.
:ino[remap] {lhs} {rhs} |mapmode-i| *:ino* *:inoremap*
:ln[oremap] {lhs} {rhs} |mapmode-l| *:ln* *:lnoremap*
:cno[remap] {lhs} {rhs} |mapmode-c| *:cno* *:cnoremap*
+:tno[remap] {lhs} {rhs} |mapmode-t| *:tno* *:tnoremap*
Map the key sequence {lhs} to {rhs} for the modes
where the map command applies. Disallow mapping of
{rhs}, to avoid nested and recursive mappings. Often
@@ -87,6 +89,7 @@ modes.
:iu[nmap] {lhs} |mapmode-i| *:iu* *:iunmap*
:lu[nmap] {lhs} |mapmode-l| *:lu* *:lunmap*
:cu[nmap] {lhs} |mapmode-c| *:cu* *:cunmap*
+:tu[nmap] {lhs} |mapmode-t| *:tu* *:tunmap*
Remove the mapping of {lhs} for the modes where the
map command applies. The mapping may remain defined
for other modes where it applies.
@@ -105,6 +108,7 @@ modes.
:imapc[lear] |mapmode-i| *:imapc* *:imapclear*
:lmapc[lear] |mapmode-l| *:lmapc* *:lmapclear*
:cmapc[lear] |mapmode-c| *:cmapc* *:cmapclear*
+:tmapc[lear] |mapmode-t| *:tmapc* *:tmapclear*
Remove ALL mappings for the modes where the map
command applies.
Use the <buffer> argument to remove buffer-local
@@ -121,6 +125,7 @@ modes.
:im[ap] |mapmode-i|
:lm[ap] |mapmode-l|
:cm[ap] |mapmode-c|
+:tm[ap] |mapmode-t|
List all key mappings for the modes where the map
command applies. Note that ":map" and ":map!" are
used most often, because they include the other modes.
@@ -135,6 +140,7 @@ modes.
:im[ap] {lhs} |mapmode-i| *:imap_l*
:lm[ap] {lhs} |mapmode-l| *:lmap_l*
:cm[ap] {lhs} |mapmode-c| *:cmap_l*
+:tm[ap] {lhs} |mapmode-t| *:tmap_l*
List the key mappings for the key sequences starting
with {lhs} in the modes where the map command applies.
@@ -288,9 +294,9 @@ as a special key.
1.3 MAPPING AND MODES *:map-modes*
- *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o*
+ *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o* *mapmode-t*
-There are six sets of mappings
+There are seven sets of mappings
- For Normal mode: When typing commands.
- For Visual mode: When typing commands while the Visual area is highlighted.
- For Select mode: like Visual mode but typing text replaces the selection.
@@ -298,6 +304,7 @@ There are six sets of mappings
etc.). See below: |omap-info|.
- For Insert mode. These are also used in Replace mode.
- For Command-line mode: When entering a ":" or "/" command.
+- For Terminal mode: When typing in a |:terminal| buffer.
Special case: While typing a count for a command in Normal mode, mapping zero
is disabled. This makes it possible to map zero without making it impossible
@@ -316,6 +323,7 @@ Overview of which map command works in which mode. More details below.
:imap :inoremap :iunmap Insert
:lmap :lnoremap :lunmap Insert, Command-line, Lang-Arg
:cmap :cnoremap :cunmap Command-line
+:tmap :tnoremap :tunmap Terminal
COMMANDS MODES ~
diff --git a/runtime/doc/nvim.txt b/runtime/doc/nvim.txt
index 904fb3c16c..7dfbbd0cf0 100644
--- a/runtime/doc/nvim.txt
+++ b/runtime/doc/nvim.txt
@@ -18,10 +18,13 @@ Transitioning from Vim *nvim-from-vim*
To start the transition, link your previous configuration so Nvim can use it:
>
- mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
- ln -s ~/.vim $XDG_CONFIG_HOME/nvim
- ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim
+ mkdir ~/.config
+ ln -s ~/.vim ~/.config/nvim
+ ln -s ~/.vimrc ~/.config/nvim/init.vim
<
+Note: If your system sets `$XDG_CONFIG_HOME`, use that instead of `~/.config`
+in the code above. Nvim follows the XDG |base-directories| convention.
+
See |provider-python| and |provider-clipboard| for additional software you
might need to use some features.
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 4296ef6490..8f7dc0dbf0 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -10,6 +10,7 @@ Embedded terminal emulator *terminal-emulator*
2. Spawning |terminal-emulator-spawning|
3. Input |terminal-emulator-input|
4. Configuration |terminal-emulator-configuration|
+5. Status Variables |terminal-emulator-status|
==============================================================================
1. Introduction *terminal-emulator-intro*
@@ -113,4 +114,25 @@ The terminal cursor can be highlighted via |hl-TermCursor| and
|hl-TermCursorNC|.
==============================================================================
+5. Status Variables *terminal-emulator-status*
+
+Terminal buffers maintain some information about the terminal in buffer-local
+variables:
+
+- *b:term_title* The settable title of the terminal, typically displayed in
+ the window title or tab title of a graphical terminal emulator. Programs
+ running in the terminal can set this title via an escape sequence.
+- *b:terminal_job_id* The nvim job ID of the job running in the terminal. See
+ |job-control| for more information.
+- *b:terminal_job_pid* The PID of the top-level process running in the
+ terminal.
+
+These variables will have a value by the time the TermOpen autocmd runs, and
+will continue to have a value for the lifetime of the terminal buffer, making
+them suitable for use in 'statusline'. For example, to show the terminal title
+as the status line:
+>
+ :autocmd TermOpen * setlocal statusline=%{b:term_title}
+<
+==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index db5c61879c..7380fb9346 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -88,6 +88,25 @@ the |:CheckHealth| command to diagnose your setup.
save to a file or copy to the clipboard.
==============================================================================
+Ruby integration *provider-ruby*
+
+Nvim supports the Vim legacy |ruby-vim| interface via external Ruby
+interpreters connected via |RPC|.
+
+
+RUBY QUICKSTART ~
+
+To use Vim Ruby plugins with Nvim, just install the latest `neovim` RubyGem: >
+ $ gem install neovim
+
+
+RUBY PROVIDER CONFIGURATION ~
+ *g:loaded_ruby_provider*
+To disable Ruby support: >
+ let g:loaded_ruby_provider = 1
+
+
+==============================================================================
Clipboard integration *provider-clipboard* *clipboard*
Nvim has no direct connection to the system clipboard. Instead it is
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 236ed65f46..8249f8e71f 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -14,6 +14,7 @@ Starting Vim *starting*
6. Saving settings |save-settings|
7. Views and Sessions |views-sessions|
8. The ShaDa file |shada-file|
+9. Base Directories |base-directories|
==============================================================================
1. Vim arguments *vim-arguments*
@@ -382,7 +383,7 @@ accordingly. Vim proceeds in this order:
name, "init.vim" is Neovim specific location for vimrc file. Also see
|vimrc-intro|.
- Places for your personal initializations:
+ Places for your personal initializations (see |base-directories|):
Unix $XDG_CONFIG_HOME/nvim/init.vim
(default for $XDG_CONFIG_HOME is ~/.config)
Windows $XDG_CONFIG_HOME/nvim/init.vim
@@ -1083,7 +1084,7 @@ even if other entries (with known name/type/etc) are merged. |shada-merging|
SHADA FILE NAME *shada-file-name*
- The default name of the ShaDa file is "$XDG_DATA_HOME/nvim/shada/main.shada"
- for Unix. Default for $XDG_DATA_HOME is ~/.local/share.
+ for Unix. Default for $XDG_DATA_HOME is ~/.local/share. |base-directories|
- The 'n' flag in the 'shada' option can be used to specify another ShaDa
file name |'shada'|.
- The "-i" Vim argument can be used to set another file name, |-i|. When the
@@ -1370,4 +1371,40 @@ file when reading and include:
either contains more then one MessagePack object or it does not contain
complete MessagePack object.
+==============================================================================
+9. Base Directories *base-directories* *xdg*
+
+Nvim conforms to the XDG Base Directory Specification for application
+configuration and data file locations. This just means Nvim looks for some
+optional settings and uses them if they exist, otherwise defaults are chosen.
+https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
+
+CONFIGURATION DIRECTORY *$XDG_CONFIG_HOME*
+
+ Base directory default:
+ Unix: ~/.config
+ Windows: ~/AppData/Local
+
+ Nvim directory:
+ Unix: ~/.config/nvim/
+ Windows: ~/AppData/Local/nvim/
+
+DATA DIRECTORY *$XDG_DATA_HOME*
+
+ Base directory default:
+ Unix: ~/.local/share
+ Windows: ~/AppData/Local
+
+ Nvim directory:
+ Unix: ~/.local/share/nvim/
+ Windows: ~/AppData/Local/nvim-data/
+
+Note on Windows the configuration and data directory defaults are the same
+(for lack of an alternative), but the sub-directory for data is named
+"nvim-data" to separate it from the configuration sub-directory "nvim".
+
+Throughout other sections of the user manual, the defaults are used as generic
+placeholders, e.g. where "~/.config" is mentioned it should be understood to
+mean "$XDG_CONFIG_HOME or ~/.config".
+
vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index eb813866da..a1bf379d86 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -417,7 +417,7 @@ m *+xpm_w32* Win32 GUI only: pixmap support |w32-xpm-support|
the screen, put the commands in a function and call it
with ":silent call Function()".
Alternatives are the 'verbosefile' option or
- |capture()| function, these can be used in combination
+ |execute()| function, these can be used in combination
with ":redir".
:redi[r] >> {file} Redirect messages to file {file}. Append if {file}
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index e536ea873a..937ed9e8ba 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -98,7 +98,7 @@ Commands:
|:CheckHealth|
Functions:
- |capture()|
+ |execute()| works with |:redir|
Events:
|TabNew|
@@ -202,13 +202,12 @@ Additional differences:
==============================================================================
5. Missing legacy features *nvim-features-missing*
- *if_ruby* *if_lua* *if_perl* *if_mzscheme* *if_tcl*
+ *if_lua* *if_perl* *if_mzscheme* *if_tcl*
These legacy Vim features may be implemented in the future, but they are not
planned for the current milestone.
- vim.bindeval() (new feature in Vim 7.4 Python interface)
-- |if_ruby|
- |if_lua|
- |if_perl|
- |if_mzscheme|
diff --git a/runtime/macros/justify.vim b/runtime/macros/justify.vim
index 4ef3bf95fa..011a911401 100644
--- a/runtime/macros/justify.vim
+++ b/runtime/macros/justify.vim
@@ -1,316 +1,3 @@
-" Function to left and right align text.
-"
-" Written by: Preben "Peppe" Guldberg <c928400@student.dtu.dk>
-" Created: 980806 14:13 (or around that time anyway)
-" Revised: 001103 00:36 (See "Revisions" below)
-
-
-" function Justify( [ textwidth [, maxspaces [, indent] ] ] )
-"
-" Justify() will left and right align a line by filling in an
-" appropriate amount of spaces. Extra spaces are added to existing
-" spaces starting from the right side of the line. As an example, the
-" following documentation has been justified.
-"
-" The function takes the following arguments:
-
-" textwidth argument
-" ------------------
-" If not specified, the value of the 'textwidth' option is used. If
-" 'textwidth' is zero a value of 80 is used.
-"
-" Additionally the arguments 'tw' and '' are accepted. The value of
-" 'textwidth' will be used. These are handy, if you just want to specify
-" the maxspaces argument.
-
-" maxspaces argument
-" ------------------
-" If specified, alignment will only be done, if the longest space run
-" after alignment is no longer than maxspaces.
-"
-" An argument of '' is accepted, should the user like to specify all
-" arguments.
-"
-" To aid user defined commands, negative values are accepted aswell.
-" Using a negative value specifies the default behaviour: any length of
-" space runs will be used to justify the text.
-
-" indent argument
-" ---------------
-" This argument specifies how a line should be indented. The default is
-" to keep the current indentation.
-"
-" Negative values: Keep current amount of leading whitespace.
-" Positive values: Indent all lines with leading whitespace using this
-" amount of whitespace.
-"
-" Note that the value 0, needs to be quoted as a string. This value
-" leads to a left flushed text.
-"
-" Additionally units of 'shiftwidth'/'sw' and 'tabstop'/'ts' may be
-" added. In this case, if the value of indent is positive, the amount of
-" whitespace to be added will be multiplied by the value of the
-" 'shiftwidth' and 'tabstop' settings. If these units are used, the
-" argument must be given as a string, eg. Justify('','','2sw').
-"
-" If the values of 'sw' or 'tw' are negative, they are treated as if
-" they were 0, which means that the text is flushed left. There is no
-" check if a negative number prefix is used to change the sign of a
-" negative 'sw' or 'ts' value.
-"
-" As with the other arguments, '' may be used to get the default
-" behaviour.
-
-
-" Notes:
-"
-" If the line, adjusted for space runs and leading/trailing whitespace,
-" is wider than the used textwidth, the line will be left untouched (no
-" whitespace removed). This should be equivalent to the behaviour of
-" :left, :right and :center.
-"
-" If the resulting line is shorter than the used textwidth it is left
-" untouched.
-"
-" All space runs in the line are truncated before the alignment is
-" carried out.
-"
-" If you have set 'noexpandtab', :retab! is used to replace space runs
-" with whitespace using the value of 'tabstop'. This should be
-" conformant with :left, :right and :center.
-"
-" If joinspaces is set, an extra space is added after '.', '?' and '!'.
-" If 'cpooptions' include 'j', extra space is only added after '.'.
-" (This may on occasion conflict with maxspaces.)
-
-
-" Related mappings:
-"
-" Mappings that will align text using the current text width, using at
-" most four spaces in a space run and keeping current indentation.
-nmap _j :%call Justify('tw',4)<CR>
-vmap _j :call Justify('tw',4)<CR>
-"
-" Mappings that will remove space runs and format lines (might be useful
-" prior to aligning the text).
-nmap ,gq :%s/\s\+/ /g<CR>gq1G
-vmap ,gq :s/\s\+/ /g<CR>gvgq
-
-
-" User defined command:
-"
-" The following is an ex command that works as a shortcut to the Justify
-" function. Arguments to Justify() can be added after the command.
-com! -range -nargs=* Justify <line1>,<line2>call Justify(<f-args>)
-"
-" The following commands are all equivalent:
-"
-" 1. Simplest use of Justify():
-" :call Justify()
-" :Justify
-"
-" 2. The _j mapping above via the ex command:
-" :%Justify tw 4
-"
-" 3. Justify visualised text at 72nd column while indenting all
-" previously indented text two shiftwidths
-" :'<,'>call Justify(72,'','2sw')
-" :'<,'>Justify 72 -1 2sw
-"
-" This documentation has been justified using the following command:
-":se et|kz|1;/^" function Justify(/+,'z-g/^" /s/^" //|call Justify(70,3)|s/^/" /
-
-" Revisions:
-" 001103: If 'joinspaces' was set, calculations could be wrong.
-" Tabs at start of line could also lead to errors.
-" Use setline() instead of "exec 's/foo/bar/' - safer.
-" Cleaned up the code a bit.
-"
-" Todo: Convert maps to the new script specific form
-
-" Error function
-function! Justify_error(message)
- echohl Error
- echo "Justify([tw, [maxspaces [, indent]]]): " . a:message
- echohl None
-endfunction
-
-
-" Now for the real thing
-function! Justify(...) range
-
- if a:0 > 3
- call Justify_error("Too many arguments (max 3)")
- return 1
- endif
-
- " Set textwidth (accept 'tw' and '' as arguments)
- if a:0 >= 1
- if a:1 =~ '^\(tw\)\=$'
- let tw = &tw
- elseif a:1 =~ '^\d\+$'
- let tw = a:1
- else
- call Justify_error("tw must be a number (>0), '' or 'tw'")
- return 2
- endif
- else
- let tw = &tw
- endif
- if tw == 0
- let tw = 80
- endif
-
- " Set maximum number of spaces between WORDs
- if a:0 >= 2
- if a:2 == ''
- let maxspaces = tw
- elseif a:2 =~ '^-\d\+$'
- let maxspaces = tw
- elseif a:2 =~ '^\d\+$'
- let maxspaces = a:2
- else
- call Justify_error("maxspaces must be a number or ''")
- return 3
- endif
- else
- let maxspaces = tw
- endif
- if maxspaces <= 1
- call Justify_error("maxspaces should be larger than 1")
- return 4
- endif
-
- " Set the indentation style (accept sw and ts units)
- let indent_fix = ''
- if a:0 >= 3
- if (a:3 == '') || a:3 =~ '^-[1-9]\d*\(shiftwidth\|sw\|tabstop\|ts\)\=$'
- let indent = -1
- elseif a:3 =~ '^-\=0\(shiftwidth\|sw\|tabstop\|ts\)\=$'
- let indent = 0
- elseif a:3 =~ '^\d\+\(shiftwidth\|sw\|tabstop\|ts\)\=$'
- let indent = substitute(a:3, '\D', '', 'g')
- elseif a:3 =~ '^\(shiftwidth\|sw\|tabstop\|ts\)$'
- let indent = 1
- else
- call Justify_error("indent: a number with 'sw'/'ts' unit")
- return 5
- endif
- if indent >= 0
- while indent > 0
- let indent_fix = indent_fix . ' '
- let indent = indent - 1
- endwhile
- let indent_sw = 0
- if a:3 =~ '\(shiftwidth\|sw\)'
- let indent_sw = &sw
- elseif a:3 =~ '\(tabstop\|ts\)'
- let indent_sw = &ts
- endif
- let indent_fix2 = ''
- while indent_sw > 0
- let indent_fix2 = indent_fix2 . indent_fix
- let indent_sw = indent_sw - 1
- endwhile
- let indent_fix = indent_fix2
- endif
- else
- let indent = -1
- endif
-
- " Avoid substitution reports
- let save_report = &report
- set report=1000000
-
- " Check 'joinspaces' and 'cpo'
- if &js == 1
- if &cpo =~ 'j'
- let join_str = '\(\. \)'
- else
- let join_str = '\([.!?!] \)'
- endif
- endif
-
- let cur = a:firstline
- while cur <= a:lastline
-
- let str_orig = getline(cur)
- let save_et = &et
- set et
- exec cur . "retab"
- let &et = save_et
- let str = getline(cur)
-
- let indent_str = indent_fix
- let indent_n = strlen(indent_str)
- " Shall we remember the current indentation
- if indent < 0
- let indent_orig = matchstr(str_orig, '^\s*')
- if strlen(indent_orig) > 0
- let indent_str = indent_orig
- let indent_n = strlen(matchstr(str, '^\s*'))
- endif
- endif
-
- " Trim trailing, leading and running whitespace
- let str = substitute(str, '\s\+$', '', '')
- let str = substitute(str, '^\s\+', '', '')
- let str = substitute(str, '\s\+', ' ', 'g')
- let str_n = strdisplaywidth(str)
-
- " Possible addition of space after punctuation
- if exists("join_str")
- let str = substitute(str, join_str, '\1 ', 'g')
- endif
- let join_n = strdisplaywidth(str) - str_n
-
- " Can extraspaces be added?
- " Note that str_n may be less than strlen(str) [joinspaces above]
- if strdisplaywidth(str) <= tw - indent_n && str_n > 0
- " How many spaces should be added
- let s_add = tw - str_n - indent_n - join_n
- let s_nr = strlen(substitute(str, '\S', '', 'g') ) - join_n
- let s_dup = s_add / s_nr
- let s_mod = s_add % s_nr
-
- " Test if the changed line fits with tw
- if 0 <= (str_n + (maxspaces - 1)*s_nr + indent_n) - tw
-
- " Duplicate spaces
- while s_dup > 0
- let str = substitute(str, '\( \+\)', ' \1', 'g')
- let s_dup = s_dup - 1
- endwhile
-
- " Add extra spaces from the end
- while s_mod > 0
- let str = substitute(str, '\(\(\s\+\S\+\)\{' . s_mod . '}\)$', ' \1', '')
- let s_mod = s_mod - 1
- endwhile
-
- " Indent the line
- if indent_n > 0
- let str = substitute(str, '^', indent_str, '' )
- endif
-
- " Replace the line
- call setline(cur, str)
-
- " Convert to whitespace
- if &et == 0
- exec cur . 'retab!'
- endif
-
- endif " Change of line
- endif " Possible change
-
- let cur = cur + 1
- endwhile
-
- norm ^
-
- let &report = save_report
-
-endfunction
-
-" EOF vim: tw=78 ts=8 sw=4 sts=4 noet ai
+" Load the justify package.
+" For those users who were loading the justify plugin from here.
+packadd justify
diff --git a/runtime/macros/shellmenu.vim b/runtime/macros/shellmenu.vim
index 6175d1d9a6..4eb72a556a 100644
--- a/runtime/macros/shellmenu.vim
+++ b/runtime/macros/shellmenu.vim
@@ -1,94 +1,3 @@
-" When you're writing shell scripts and you are in doubt which test to use,
-" which shell environment variables are defined, what the syntax of the case
-" statement is, and you need to invoke 'man sh'?
-"
-" Your problems are over now!
-"
-" Attached is a Vim script file for turning gvim into a shell script editor.
-" It may also be used as an example how to use menus in Vim.
-"
-" Written by: Lennart Schultz <les@dmi.min.dk>
-
-imenu Stmts.for for in do doneki kk0elli
-imenu Stmts.case case in ) ;; esacbki k0elli
-imenu Stmts.if if then fiki kk0elli
-imenu Stmts.if-else if then else fiki kki kk0elli
-imenu Stmts.elif elif then ki kk0elli
-imenu Stmts.while while do doneki kk0elli
-imenu Stmts.break break
-imenu Stmts.continue continue
-imenu Stmts.function () { }ki k0i
-imenu Stmts.return return
-imenu Stmts.return-true return 0
-imenu Stmts.return-false return 1
-imenu Stmts.exit exit
-imenu Stmts.shift shift
-imenu Stmts.trap trap
-imenu Test.existence [ -e ]hi
-imenu Test.existence - file [ -f ]hi
-imenu Test.existence - file (not empty) [ -s ]hi
-imenu Test.existence - directory [ -d ]hi
-imenu Test.existence - executable [ -x ]hi
-imenu Test.existence - readable [ -r ]hi
-imenu Test.existence - writable [ -w ]hi
-imenu Test.String is empty [ x = "x$" ]hhi
-imenu Test.String is not empty [ x != "x$" ]hhi
-imenu Test.Strings is equal [ "" = "" ]hhhhhhhi
-imenu Test.Strings is not equal [ "" != "" ]hhhhhhhhi
-imenu Test.Values is greater than [ -gt ]hhhhhhi
-imenu Test.Values is greater equal [ -ge ]hhhhhhi
-imenu Test.Values is equal [ -eq ]hhhhhhi
-imenu Test.Values is not equal [ -ne ]hhhhhhi
-imenu Test.Values is less than [ -lt ]hhhhhhi
-imenu Test.Values is less equal [ -le ]hhhhhhi
-imenu ParmSub.Substitute word if parm not set ${:-}hhi
-imenu ParmSub.Set parm to word if not set ${:=}hhi
-imenu ParmSub.Substitute word if parm set else nothing ${:+}hhi
-imenu ParmSub.If parm not set print word and exit ${:?}hhi
-imenu SpShVars.Number of positional parameters ${#}
-imenu SpShVars.All positional parameters (quoted spaces) ${*}
-imenu SpShVars.All positional parameters (unquoted spaces) ${@}
-imenu SpShVars.Flags set ${-}
-imenu SpShVars.Return code of last command ${?}
-imenu SpShVars.Process number of this shell ${$}
-imenu SpShVars.Process number of last background command ${!}
-imenu Environ.HOME ${HOME}
-imenu Environ.PATH ${PATH}
-imenu Environ.CDPATH ${CDPATH}
-imenu Environ.MAIL ${MAIL}
-imenu Environ.MAILCHECK ${MAILCHECK}
-imenu Environ.PS1 ${PS1}
-imenu Environ.PS2 ${PS2}
-imenu Environ.IFS ${IFS}
-imenu Environ.SHACCT ${SHACCT}
-imenu Environ.SHELL ${SHELL}
-imenu Environ.LC_CTYPE ${LC_CTYPE}
-imenu Environ.LC_MESSAGES ${LC_MESSAGES}
-imenu Builtins.cd cd
-imenu Builtins.echo echo
-imenu Builtins.eval eval
-imenu Builtins.exec exec
-imenu Builtins.export export
-imenu Builtins.getopts getopts
-imenu Builtins.hash hash
-imenu Builtins.newgrp newgrp
-imenu Builtins.pwd pwd
-imenu Builtins.read read
-imenu Builtins.readonly readonly
-imenu Builtins.return return
-imenu Builtins.times times
-imenu Builtins.type type
-imenu Builtins.umask umask
-imenu Builtins.wait wait
-imenu Set.set set
-imenu Set.unset unset
-imenu Set.mark modified or modified variables set -a
-imenu Set.exit when command returns non-zero exit code set -e
-imenu Set.Disable file name generation set -f
-imenu Set.remember function commands set -h
-imenu Set.All keyword arguments are placed in the environment set -k
-imenu Set.Read commands but do not execute them set -n
-imenu Set.Exit after reading and executing one command set -t
-imenu Set.Treat unset variables as an error when substituting set -u
-imenu Set.Print shell input lines as they are read set -v
-imenu Set.Print commands and their arguments as they are executed set -x
+" Load the shellmenu package.
+" For those users who were loading the shellmenu plugin from here.
+packadd shellmenu
diff --git a/runtime/macros/swapmous.vim b/runtime/macros/swapmous.vim
index 8b85be050b..5884d83473 100644
--- a/runtime/macros/swapmous.vim
+++ b/runtime/macros/swapmous.vim
@@ -1,22 +1,3 @@
-" These macros swap the left and right mouse buttons (for left handed)
-" Don't forget to do ":set mouse=a" or the mouse won't work at all
-noremap <LeftMouse> <RightMouse>
-noremap <2-LeftMouse> <2-RightMouse>
-noremap <3-LeftMouse> <3-RightMouse>
-noremap <4-LeftMouse> <4-RightMouse>
-noremap <LeftDrag> <RightDrag>
-noremap <LeftRelease> <RightRelease>
-noremap <RightMouse> <LeftMouse>
-noremap <2-RightMouse> <2-LeftMouse>
-noremap <3-RightMouse> <3-LeftMouse>
-noremap <4-RightMouse> <4-LeftMouse>
-noremap <RightDrag> <LeftDrag>
-noremap <RightRelease> <LeftRelease>
-noremap g<LeftMouse> <C-RightMouse>
-noremap g<RightMouse> <C-LeftMouse>
-noremap! <LeftMouse> <RightMouse>
-noremap! <LeftDrag> <RightDrag>
-noremap! <LeftRelease> <RightRelease>
-noremap! <RightMouse> <LeftMouse>
-noremap! <RightDrag> <LeftDrag>
-noremap! <RightRelease> <LeftRelease>
+" Load the swapmouse package.
+" For those users who were loading the swapmous plugin from here.
+packadd swapmouse
diff --git a/runtime/pack/dist/opt/justify/plugin/justify.vim b/runtime/pack/dist/opt/justify/plugin/justify.vim
new file mode 100644
index 0000000000..4ef3bf95fa
--- /dev/null
+++ b/runtime/pack/dist/opt/justify/plugin/justify.vim
@@ -0,0 +1,316 @@
+" Function to left and right align text.
+"
+" Written by: Preben "Peppe" Guldberg <c928400@student.dtu.dk>
+" Created: 980806 14:13 (or around that time anyway)
+" Revised: 001103 00:36 (See "Revisions" below)
+
+
+" function Justify( [ textwidth [, maxspaces [, indent] ] ] )
+"
+" Justify() will left and right align a line by filling in an
+" appropriate amount of spaces. Extra spaces are added to existing
+" spaces starting from the right side of the line. As an example, the
+" following documentation has been justified.
+"
+" The function takes the following arguments:
+
+" textwidth argument
+" ------------------
+" If not specified, the value of the 'textwidth' option is used. If
+" 'textwidth' is zero a value of 80 is used.
+"
+" Additionally the arguments 'tw' and '' are accepted. The value of
+" 'textwidth' will be used. These are handy, if you just want to specify
+" the maxspaces argument.
+
+" maxspaces argument
+" ------------------
+" If specified, alignment will only be done, if the longest space run
+" after alignment is no longer than maxspaces.
+"
+" An argument of '' is accepted, should the user like to specify all
+" arguments.
+"
+" To aid user defined commands, negative values are accepted aswell.
+" Using a negative value specifies the default behaviour: any length of
+" space runs will be used to justify the text.
+
+" indent argument
+" ---------------
+" This argument specifies how a line should be indented. The default is
+" to keep the current indentation.
+"
+" Negative values: Keep current amount of leading whitespace.
+" Positive values: Indent all lines with leading whitespace using this
+" amount of whitespace.
+"
+" Note that the value 0, needs to be quoted as a string. This value
+" leads to a left flushed text.
+"
+" Additionally units of 'shiftwidth'/'sw' and 'tabstop'/'ts' may be
+" added. In this case, if the value of indent is positive, the amount of
+" whitespace to be added will be multiplied by the value of the
+" 'shiftwidth' and 'tabstop' settings. If these units are used, the
+" argument must be given as a string, eg. Justify('','','2sw').
+"
+" If the values of 'sw' or 'tw' are negative, they are treated as if
+" they were 0, which means that the text is flushed left. There is no
+" check if a negative number prefix is used to change the sign of a
+" negative 'sw' or 'ts' value.
+"
+" As with the other arguments, '' may be used to get the default
+" behaviour.
+
+
+" Notes:
+"
+" If the line, adjusted for space runs and leading/trailing whitespace,
+" is wider than the used textwidth, the line will be left untouched (no
+" whitespace removed). This should be equivalent to the behaviour of
+" :left, :right and :center.
+"
+" If the resulting line is shorter than the used textwidth it is left
+" untouched.
+"
+" All space runs in the line are truncated before the alignment is
+" carried out.
+"
+" If you have set 'noexpandtab', :retab! is used to replace space runs
+" with whitespace using the value of 'tabstop'. This should be
+" conformant with :left, :right and :center.
+"
+" If joinspaces is set, an extra space is added after '.', '?' and '!'.
+" If 'cpooptions' include 'j', extra space is only added after '.'.
+" (This may on occasion conflict with maxspaces.)
+
+
+" Related mappings:
+"
+" Mappings that will align text using the current text width, using at
+" most four spaces in a space run and keeping current indentation.
+nmap _j :%call Justify('tw',4)<CR>
+vmap _j :call Justify('tw',4)<CR>
+"
+" Mappings that will remove space runs and format lines (might be useful
+" prior to aligning the text).
+nmap ,gq :%s/\s\+/ /g<CR>gq1G
+vmap ,gq :s/\s\+/ /g<CR>gvgq
+
+
+" User defined command:
+"
+" The following is an ex command that works as a shortcut to the Justify
+" function. Arguments to Justify() can be added after the command.
+com! -range -nargs=* Justify <line1>,<line2>call Justify(<f-args>)
+"
+" The following commands are all equivalent:
+"
+" 1. Simplest use of Justify():
+" :call Justify()
+" :Justify
+"
+" 2. The _j mapping above via the ex command:
+" :%Justify tw 4
+"
+" 3. Justify visualised text at 72nd column while indenting all
+" previously indented text two shiftwidths
+" :'<,'>call Justify(72,'','2sw')
+" :'<,'>Justify 72 -1 2sw
+"
+" This documentation has been justified using the following command:
+":se et|kz|1;/^" function Justify(/+,'z-g/^" /s/^" //|call Justify(70,3)|s/^/" /
+
+" Revisions:
+" 001103: If 'joinspaces' was set, calculations could be wrong.
+" Tabs at start of line could also lead to errors.
+" Use setline() instead of "exec 's/foo/bar/' - safer.
+" Cleaned up the code a bit.
+"
+" Todo: Convert maps to the new script specific form
+
+" Error function
+function! Justify_error(message)
+ echohl Error
+ echo "Justify([tw, [maxspaces [, indent]]]): " . a:message
+ echohl None
+endfunction
+
+
+" Now for the real thing
+function! Justify(...) range
+
+ if a:0 > 3
+ call Justify_error("Too many arguments (max 3)")
+ return 1
+ endif
+
+ " Set textwidth (accept 'tw' and '' as arguments)
+ if a:0 >= 1
+ if a:1 =~ '^\(tw\)\=$'
+ let tw = &tw
+ elseif a:1 =~ '^\d\+$'
+ let tw = a:1
+ else
+ call Justify_error("tw must be a number (>0), '' or 'tw'")
+ return 2
+ endif
+ else
+ let tw = &tw
+ endif
+ if tw == 0
+ let tw = 80
+ endif
+
+ " Set maximum number of spaces between WORDs
+ if a:0 >= 2
+ if a:2 == ''
+ let maxspaces = tw
+ elseif a:2 =~ '^-\d\+$'
+ let maxspaces = tw
+ elseif a:2 =~ '^\d\+$'
+ let maxspaces = a:2
+ else
+ call Justify_error("maxspaces must be a number or ''")
+ return 3
+ endif
+ else
+ let maxspaces = tw
+ endif
+ if maxspaces <= 1
+ call Justify_error("maxspaces should be larger than 1")
+ return 4
+ endif
+
+ " Set the indentation style (accept sw and ts units)
+ let indent_fix = ''
+ if a:0 >= 3
+ if (a:3 == '') || a:3 =~ '^-[1-9]\d*\(shiftwidth\|sw\|tabstop\|ts\)\=$'
+ let indent = -1
+ elseif a:3 =~ '^-\=0\(shiftwidth\|sw\|tabstop\|ts\)\=$'
+ let indent = 0
+ elseif a:3 =~ '^\d\+\(shiftwidth\|sw\|tabstop\|ts\)\=$'
+ let indent = substitute(a:3, '\D', '', 'g')
+ elseif a:3 =~ '^\(shiftwidth\|sw\|tabstop\|ts\)$'
+ let indent = 1
+ else
+ call Justify_error("indent: a number with 'sw'/'ts' unit")
+ return 5
+ endif
+ if indent >= 0
+ while indent > 0
+ let indent_fix = indent_fix . ' '
+ let indent = indent - 1
+ endwhile
+ let indent_sw = 0
+ if a:3 =~ '\(shiftwidth\|sw\)'
+ let indent_sw = &sw
+ elseif a:3 =~ '\(tabstop\|ts\)'
+ let indent_sw = &ts
+ endif
+ let indent_fix2 = ''
+ while indent_sw > 0
+ let indent_fix2 = indent_fix2 . indent_fix
+ let indent_sw = indent_sw - 1
+ endwhile
+ let indent_fix = indent_fix2
+ endif
+ else
+ let indent = -1
+ endif
+
+ " Avoid substitution reports
+ let save_report = &report
+ set report=1000000
+
+ " Check 'joinspaces' and 'cpo'
+ if &js == 1
+ if &cpo =~ 'j'
+ let join_str = '\(\. \)'
+ else
+ let join_str = '\([.!?!] \)'
+ endif
+ endif
+
+ let cur = a:firstline
+ while cur <= a:lastline
+
+ let str_orig = getline(cur)
+ let save_et = &et
+ set et
+ exec cur . "retab"
+ let &et = save_et
+ let str = getline(cur)
+
+ let indent_str = indent_fix
+ let indent_n = strlen(indent_str)
+ " Shall we remember the current indentation
+ if indent < 0
+ let indent_orig = matchstr(str_orig, '^\s*')
+ if strlen(indent_orig) > 0
+ let indent_str = indent_orig
+ let indent_n = strlen(matchstr(str, '^\s*'))
+ endif
+ endif
+
+ " Trim trailing, leading and running whitespace
+ let str = substitute(str, '\s\+$', '', '')
+ let str = substitute(str, '^\s\+', '', '')
+ let str = substitute(str, '\s\+', ' ', 'g')
+ let str_n = strdisplaywidth(str)
+
+ " Possible addition of space after punctuation
+ if exists("join_str")
+ let str = substitute(str, join_str, '\1 ', 'g')
+ endif
+ let join_n = strdisplaywidth(str) - str_n
+
+ " Can extraspaces be added?
+ " Note that str_n may be less than strlen(str) [joinspaces above]
+ if strdisplaywidth(str) <= tw - indent_n && str_n > 0
+ " How many spaces should be added
+ let s_add = tw - str_n - indent_n - join_n
+ let s_nr = strlen(substitute(str, '\S', '', 'g') ) - join_n
+ let s_dup = s_add / s_nr
+ let s_mod = s_add % s_nr
+
+ " Test if the changed line fits with tw
+ if 0 <= (str_n + (maxspaces - 1)*s_nr + indent_n) - tw
+
+ " Duplicate spaces
+ while s_dup > 0
+ let str = substitute(str, '\( \+\)', ' \1', 'g')
+ let s_dup = s_dup - 1
+ endwhile
+
+ " Add extra spaces from the end
+ while s_mod > 0
+ let str = substitute(str, '\(\(\s\+\S\+\)\{' . s_mod . '}\)$', ' \1', '')
+ let s_mod = s_mod - 1
+ endwhile
+
+ " Indent the line
+ if indent_n > 0
+ let str = substitute(str, '^', indent_str, '' )
+ endif
+
+ " Replace the line
+ call setline(cur, str)
+
+ " Convert to whitespace
+ if &et == 0
+ exec cur . 'retab!'
+ endif
+
+ endif " Change of line
+ endif " Possible change
+
+ let cur = cur + 1
+ endwhile
+
+ norm ^
+
+ let &report = save_report
+
+endfunction
+
+" EOF vim: tw=78 ts=8 sw=4 sts=4 noet ai
diff --git a/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim
new file mode 100644
index 0000000000..6175d1d9a6
--- /dev/null
+++ b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim
@@ -0,0 +1,94 @@
+" When you're writing shell scripts and you are in doubt which test to use,
+" which shell environment variables are defined, what the syntax of the case
+" statement is, and you need to invoke 'man sh'?
+"
+" Your problems are over now!
+"
+" Attached is a Vim script file for turning gvim into a shell script editor.
+" It may also be used as an example how to use menus in Vim.
+"
+" Written by: Lennart Schultz <les@dmi.min.dk>
+
+imenu Stmts.for for in do doneki kk0elli
+imenu Stmts.case case in ) ;; esacbki k0elli
+imenu Stmts.if if then fiki kk0elli
+imenu Stmts.if-else if then else fiki kki kk0elli
+imenu Stmts.elif elif then ki kk0elli
+imenu Stmts.while while do doneki kk0elli
+imenu Stmts.break break
+imenu Stmts.continue continue
+imenu Stmts.function () { }ki k0i
+imenu Stmts.return return
+imenu Stmts.return-true return 0
+imenu Stmts.return-false return 1
+imenu Stmts.exit exit
+imenu Stmts.shift shift
+imenu Stmts.trap trap
+imenu Test.existence [ -e ]hi
+imenu Test.existence - file [ -f ]hi
+imenu Test.existence - file (not empty) [ -s ]hi
+imenu Test.existence - directory [ -d ]hi
+imenu Test.existence - executable [ -x ]hi
+imenu Test.existence - readable [ -r ]hi
+imenu Test.existence - writable [ -w ]hi
+imenu Test.String is empty [ x = "x$" ]hhi
+imenu Test.String is not empty [ x != "x$" ]hhi
+imenu Test.Strings is equal [ "" = "" ]hhhhhhhi
+imenu Test.Strings is not equal [ "" != "" ]hhhhhhhhi
+imenu Test.Values is greater than [ -gt ]hhhhhhi
+imenu Test.Values is greater equal [ -ge ]hhhhhhi
+imenu Test.Values is equal [ -eq ]hhhhhhi
+imenu Test.Values is not equal [ -ne ]hhhhhhi
+imenu Test.Values is less than [ -lt ]hhhhhhi
+imenu Test.Values is less equal [ -le ]hhhhhhi
+imenu ParmSub.Substitute word if parm not set ${:-}hhi
+imenu ParmSub.Set parm to word if not set ${:=}hhi
+imenu ParmSub.Substitute word if parm set else nothing ${:+}hhi
+imenu ParmSub.If parm not set print word and exit ${:?}hhi
+imenu SpShVars.Number of positional parameters ${#}
+imenu SpShVars.All positional parameters (quoted spaces) ${*}
+imenu SpShVars.All positional parameters (unquoted spaces) ${@}
+imenu SpShVars.Flags set ${-}
+imenu SpShVars.Return code of last command ${?}
+imenu SpShVars.Process number of this shell ${$}
+imenu SpShVars.Process number of last background command ${!}
+imenu Environ.HOME ${HOME}
+imenu Environ.PATH ${PATH}
+imenu Environ.CDPATH ${CDPATH}
+imenu Environ.MAIL ${MAIL}
+imenu Environ.MAILCHECK ${MAILCHECK}
+imenu Environ.PS1 ${PS1}
+imenu Environ.PS2 ${PS2}
+imenu Environ.IFS ${IFS}
+imenu Environ.SHACCT ${SHACCT}
+imenu Environ.SHELL ${SHELL}
+imenu Environ.LC_CTYPE ${LC_CTYPE}
+imenu Environ.LC_MESSAGES ${LC_MESSAGES}
+imenu Builtins.cd cd
+imenu Builtins.echo echo
+imenu Builtins.eval eval
+imenu Builtins.exec exec
+imenu Builtins.export export
+imenu Builtins.getopts getopts
+imenu Builtins.hash hash
+imenu Builtins.newgrp newgrp
+imenu Builtins.pwd pwd
+imenu Builtins.read read
+imenu Builtins.readonly readonly
+imenu Builtins.return return
+imenu Builtins.times times
+imenu Builtins.type type
+imenu Builtins.umask umask
+imenu Builtins.wait wait
+imenu Set.set set
+imenu Set.unset unset
+imenu Set.mark modified or modified variables set -a
+imenu Set.exit when command returns non-zero exit code set -e
+imenu Set.Disable file name generation set -f
+imenu Set.remember function commands set -h
+imenu Set.All keyword arguments are placed in the environment set -k
+imenu Set.Read commands but do not execute them set -n
+imenu Set.Exit after reading and executing one command set -t
+imenu Set.Treat unset variables as an error when substituting set -u
+imenu Set.Print shell input lines as they are read set -v
+imenu Set.Print commands and their arguments as they are executed set -x
diff --git a/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim b/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim
new file mode 100644
index 0000000000..8b85be050b
--- /dev/null
+++ b/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim
@@ -0,0 +1,22 @@
+" These macros swap the left and right mouse buttons (for left handed)
+" Don't forget to do ":set mouse=a" or the mouse won't work at all
+noremap <LeftMouse> <RightMouse>
+noremap <2-LeftMouse> <2-RightMouse>
+noremap <3-LeftMouse> <3-RightMouse>
+noremap <4-LeftMouse> <4-RightMouse>
+noremap <LeftDrag> <RightDrag>
+noremap <LeftRelease> <RightRelease>
+noremap <RightMouse> <LeftMouse>
+noremap <2-RightMouse> <2-LeftMouse>
+noremap <3-RightMouse> <3-LeftMouse>
+noremap <4-RightMouse> <4-LeftMouse>
+noremap <RightDrag> <LeftDrag>
+noremap <RightRelease> <LeftRelease>
+noremap g<LeftMouse> <C-RightMouse>
+noremap g<RightMouse> <C-LeftMouse>
+noremap! <LeftMouse> <RightMouse>
+noremap! <LeftDrag> <RightDrag>
+noremap! <LeftRelease> <RightRelease>
+noremap! <RightMouse> <LeftMouse>
+noremap! <RightDrag> <LeftDrag>
+noremap! <RightRelease> <LeftRelease>
diff --git a/runtime/plugin/matchit.vim b/runtime/plugin/matchit.vim
index 70867b1f93..8053b080e1 100644
--- a/runtime/plugin/matchit.vim
+++ b/runtime/plugin/matchit.vim
@@ -1,7 +1,8 @@
" matchit.vim: (global plugin) Extended "%" matching
-" Last Change: Fri Jan 25 10:00 AM 2008 EST
+" Last Change: Fri Jul 29 01:20 AM 2016 EST
" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
" Version: 1.13.2, for Vim 6.3+
+" Fix from Tommy Allen included.
" URL: http://www.vim.org/script.php?script_id=39
" Documentation:
@@ -254,12 +255,7 @@ function! s:Match_wrapper(word, forward, mode) range
" Fifth step: actually start moving the cursor and call searchpair().
" Later, :execute restore_cursor to get to the original screen.
- let restore_cursor = virtcol(".") . "|"
- normal! g0
- let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
- normal! H
- let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
- execute restore_cursor
+ let view = winsaveview()
call cursor(0, curcol + 1)
" normal! 0
" if curcol
@@ -273,7 +269,7 @@ function! s:Match_wrapper(word, forward, mode) range
let sp_return = searchpair(ini, mid, fin, flag, skip)
let final_position = "call cursor(" . line(".") . "," . col(".") . ")"
" Restore cursor position and original screen.
- execute restore_cursor
+ call winrestview(view)
normal! m'
if sp_return > 0
execute final_position
@@ -634,7 +630,7 @@ endfun
" idea to give it its own matching patterns.
fun! s:MultiMatch(spflag, mode)
if !exists("b:match_words") || b:match_words == ""
- return ""
+ return {}
end
let restore_options = (&ic ? "" : "no") . "ignorecase"
if exists("b:match_ignorecase")
@@ -694,15 +690,7 @@ fun! s:MultiMatch(spflag, mode)
let skip = 's:comment\|string'
endif
let skip = s:ParseSkip(skip)
- " let restore_cursor = line(".") . "G" . virtcol(".") . "|"
- " normal! H
- " let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
- let restore_cursor = virtcol(".") . "|"
- normal! g0
- let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
- normal! H
- let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
- execute restore_cursor
+ let view = winsaveview()
" Third step: call searchpair().
" Replace '\('--but not '\\('--with '\%(' and ',' with '\|'.
@@ -720,14 +708,14 @@ fun! s:MultiMatch(spflag, mode)
while level
if searchpair(openpat, '', closepat, a:spflag, skip) < 1
call s:CleanUp(restore_options, a:mode, startline, startcol)
- return ""
+ return {}
endif
let level = level - 1
endwhile
- " Restore options and return a string to restore the original position.
+ " Restore options and return view dict to restore the original position.
call s:CleanUp(restore_options, a:mode, startline, startcol)
- return restore_cursor
+ return view
endfun
" Search backwards for "if" or "while" or "<tag>" or ...