On 2015-07-21 Tuesday at 14:04 +0200 Bram Moolenaar wrote:
> Roland Eggner wrote:
> > Despite having used vim, “:help …” and “:helpgrep …” almost daily for 9 
> > years
> > I was not aware of the special effect of the equal sign in `= … ` until
> > a recent bugreport from Pavol Juhas regarding this feature.  Surprisingly
> > “:help improvements-6” hints, that this feature has been there since early
> > days of the vim-6 period.
> > 
> > My patch provided below should
> > •  improve accessibility of “:help `=” by adding references at useful points
> >    in “runtime/doc/cmdline.txt” -- currently there are no such references 
> > at all
> > •  improve “:help `=” by adding a hint, under which condition this feature 
> > can
> >    be used
> 
> Thanks!

v2:
•  “:help `-expansion”:
   Improved example and added a 2nd one.
•  “:help `=”:
   Added a 2nd example showing how to refer environment variables using
   “expand( … )”.
   Added a 3rd example showing what interesting, only in rare cases desired 
   effects are possible when the “expand( … )” call is missing and the value -- 
   not only the name -- of an environment variable is evaluated (inspired by 
   issue 385 “expansion of environment variables fails in Vim backtick 
   expression”).
•  Fixed a few typos spotted nearby.


diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -594,12 +594,13 @@ file names.  Escape the spaces to include them in a file 
name.  Example: >
        :next foo\ bar goes\ to school\
 starts editing the three files "foo bar", "goes to" and "school ".
 
 When you want to use the special characters '"' or '|' in a command, or want
 to use '%' or '#' in a file name, precede them with a backslash.  The
 backslash is not required in a range and in the ":substitute" command.
+See also |`=|.
 
                                                        *:_!*
 The '!' (bang) character after an Ex command makes the command behave in a
 different way.  The '!' should be placed immediately after the command, without
 any blanks in between.  If you insert blanks the '!' will be seen as an
 argument for the command, which has a different meaning.  For example:
@@ -746,19 +747,19 @@ 6. Ex special characters                          
*cmdline-special*
 
 Note: These are special characters in the executed command line.  If you want
 to insert special things while typing you can use the CTRL-R command.  For
 example, "%" stands for the current file name, while CTRL-R % inserts the
 current file name right away.  See |c_CTRL-R|.
 
-Note: If you want to avoid the special characters in a Vim script you may want
-to use |fnameescape()|.
+Note:  If you want to avoid the effects of special characters in a Vim script
+you may want to use |fnameescape()|.  See also |`=|.
 
 
 In Ex commands, at places where a file name can be used, the following
 characters have a special meaning.  These can also be used in the expression
-function expand() |expand()|.
+function |expand()|.
        %       Is replaced with the current file name.           *:_%* *c_%*
        #       Is replaced with the alternate file name.         *:_#* *c_#*
                This is remembered for every window.
        #n      (where n is a number) is replaced with            *:_#0* *:_#n*
                the file name of buffer n.  "#0" is the same as "#".     *c_#n*
        ##      Is replaced with all names in the argument list   *:_##* *c_##*
@@ -787,12 +788,13 @@ To avoid the special meaning of '%' and '#' insert a 
backslash before it.
 Detail: The special meaning is always escaped when there is a backslash before
 it, no matter how many backslashes.
        you type:               result  ~
           #                    alternate.file
           \#                   #
           \\#                  \#
+See also |`=|.
 
                               *:<cword>* *:<cWORD>* *:<cfile>* *<cfile>*
                               *:<sfile>* *<sfile>* *:<afile>* *<afile>*
                               *:<abuf>* *<abuf>* *:<amatch>* *<amatch>*
                               *<slnum>* *E495* *E496* *E497* *E499* *E500*
 Note: these are typed literally, they are not special keys!
@@ -930,15 +932,14 @@ name).  This is included for backwards compatibility with 
version 3.0, the
        <cWORD>         WORD under the cursor (see |WORD|)
        <cfile>         path name under the cursor
        <cfile><        idem, without extension
 
 Note: Where a file name is expected wildcards expansion is done.  On Unix the
 shell is used for this, unless it can be done internally (for speed).
-Backticks also work, like in >
+Unless in |restricted-mode|, backticks work also, like in >
        :n `echo *.c`
-(backtick expansion is not possible in |restricted-mode|)
 But expansion is only done if there are any wildcards before expanding the
 '%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
 want to expand the result of <cfile>, add a wildcard character to it.
 Examples: (alternate file name is "?readme?")
        command         expands to  ~
        :e #            :e ?readme?
@@ -948,13 +949,13 @@ Examples: (alternate file name is "?readme?")
        :cd <cfile>*    :cd {file name under cursor plus "*" and then expanded}
 
 When the expanded argument contains a "!" and it is used for a shell command
 (":!cmd", ":r !cmd" or ":w !cmd"), the "!" is escaped with a backslash to
 avoid it being expanded into a previously used command.  When the 'shell'
 option contains "sh", this is done twice, to avoid the shell trying to expand
-the "!".
+the "!".  See also |`=|.
 
                                                        *filename-backslash*
 For filesystems that use a backslash as directory separator (MS-DOS, Windows,
 OS/2), it's a bit difficult to recognize a backslash that is used to escape
 the special meaning of the next character.  The general rule is: If the
 backslash is followed by a normal file name character, it does not have a
@@ -969,12 +970,14 @@ for the file "$home" in the root directory.  A few 
examples:
        FILE NAME       INTERPRETED AS  ~
        $home           expanded to value of environment var $home
        \$home          file "$home" in current directory
        /\$home         file "$home" in root directory
        \\$home         file "\\", followed by expanded $home
 
+See also |`=|.
+
 ==============================================================================
 7. Command-line window                         *cmdline-window* *cmdwin*
                                                        *command-line-window*
 In the command-line window the command line can be edited just like editing
 text in any window.  It is a special kind of window, because you cannot leave
 it in a normal way.
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -408,31 +408,44 @@ directory.  Example: >
        :n /usr/inc**/*.h
 Finds files:
        /usr/include/types.h
        /usr/include/sys/types.h
        /usr/inc_old/types.h
                                        *backtick-expansion* *`-expansion*
-On Unix and a few other systems you can also use backticks in the file name,
-for example: >
-       :e `find . -name ver\\*.c -print`
-The backslashes before the star are required to prevent "ver*.c" to be
-expanded by the shell before executing the find program.
-This also works for most other systems, with the restriction that the
-backticks must be around the whole item.  It is not possible to have text
+On Unix and a few other systems you can also use backticks in the file name 
+argument.  E.g. add to the argument list all *.c files in and below the 
+current directory modified within 1 hour, and view the youngest *.patch file 
+in the current directory: >
+       :argadd `find . -name \\*.c -mmin -60 -print`
+       :view `ls -t *.patch  \| head -n1`
+The backslashes before the star are required to prevent the shell from 
+expanding "*.c" prior to execution of the find program.  The backslash before 
+the shell pipe symbol "|" prevents Vim from parsing it as command termination.
+This also works for most other systems, with the restriction that the 
+backticks must be around the whole item.  It is not possible to have text 
 directly before the first or just after the last backtick.
 
                                                        *`=*
 You can have the backticks expanded as a Vim expression, instead of an
 external command, by using the syntax `={expr}` e.g.: >
-       :e `=tempname()`
+       :edit `=tempname()`
+       :edit `=expand('$HOME') . '/filename with 3 ugly % | # characters'`
+       :let home = 2
+       :let username = 3              " assuming  $HOME == '/home/username'
+       :edit `=36 $HOME . '/.vimrc'`  " creates a buffer “6/.vimrc”
 The expression can contain just about anything, thus this can also be used to
 avoid the special meaning of '"', '|', '%' and '#'.  However, 'wildignore'
 does apply like to other wildcards.
-If the expression returns a string then names are to be separated with line
-breaks.  When the result is a |List| then each item is used as a name.  Line
-breaks also separate names.
+If the expression contains an unquoted environment variable reference without 
+call to |expand()|, the value of this variable -- not only its name -- is 
+evaluated as vim expression.  See also |expr-env-expand|.  If the expression 
+returns a string then names are to be separated with line breaks.  When the 
+result is a |List| then each item is used as a name.  Line breaks also 
+separate names.
+Note that such expressions are only supported at places, where a filename is 
+expected as an argument to an Ex command.
 
                                                        *++opt* *[++opt]*
 The [++opt] argument can be used to force the value of 'fileformat',
 'fileencoding' or 'binary' to a value for one command, and to specify the
 behavior for bad characters.  The form is: >
        ++{optname}
@@ -608,13 +621,13 @@ list of the current window.
                        Also see |++opt| and |+cmd|.
                        {not in Vi}
 
 :[count]arga[dd] {name} ..                     *:arga* *:argadd* *E479*
 :[count]arga[dd]
                        Add the {name}s to the argument list.  When {name} is
-                       omitted at the current buffer name to the argument
+                       omitted add the current buffer name to the argument
                        list.
                        If [count] is omitted, the {name}s are added just
                        after the current entry in the argument list.
                        Otherwise they are added after the [count]'th file.
                        If the argument list is "a b c", and "b" is the
                        current argument, then these commands result in:



-- 
Best regards,
Roland Eggner

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: pgp7F0OIMMA9B.pgp
Description: PGP signature

Raspunde prin e-mail lui