Hi Bram


On 2015-07-22 Wednesday at 00:25 +0200 Roland Eggner wrote:
> 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.

v3:
Updated for vim-7.4.794.
Previous versions accidentally where based on 7.4.529, sorry.


--- runtime/doc/cmdline.txt~    2015-07-21 19:19:13.000000000 +0200
+++ runtime/doc/cmdline.txt     2015-07-22 01:09:52.340233741 +0200
@@ -747,19 +747,19 @@ output.
 
 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()|.  Also see |`=|.
+Note:  If you want to avoid the effects of special characters in a Vim script
+you may want to use |fnameescape()|.  Also see |`=|.
 
 
 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_##*
@@ -789,12 +789,13 @@ Detail: The special meaning is always es
 it, no matter how many backslashes.
        you type:               result  ~
           #                    alternate.file
           \#                   #
           \\#                  \#
 Also see |`=|.
+
                               *:<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!
        <cword>    is replaced with the word under the cursor (like |star|)
@@ -809,13 +810,13 @@ Note: these are typed literally, they ar
                   buffer).
        <amatch>   When executing autocommands, is replaced with the match for
                   which this autocommand was executed.  It differs from
                   <afile> only when the file name isn't used to match with
                   (for FileType, Syntax and SpellFileMissing events).
        <sfile>    When executing a ":source" command, is replaced with the
-                  file name of the sourced file.  *E498* 
+                  file name of the sourced file.  *E498*
                   When executing a function, is replaced with
                   "function {function-name}"; function call nesting is
                   indicated like this:
                   "function {function-name1}..{function-name2}".  Note that
                   filename-modifiers are useless when <sfile> is used inside
                   a function.
@@ -931,15 +932,14 @@ name).  This is included for backwards c
        <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?
--- runtime/doc/editing.txt~    2015-07-21 19:19:13.000000000 +0200
+++ runtime/doc/editing.txt     2015-07-22 01:33:28.710243386 +0200
@@ -409,33 +409,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.
-Note that such expressions are only supported in places where a filename is
-expected as an argument to an Ex-command.
+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}
@@ -1362,13 +1373,13 @@ There are a few things to remember when
 - Make sure the 'binary' option is set BEFORE loading the
   file.  Otherwise both <CR> <NL> and <NL> are considered to end a line
   and when the file is written the <NL> will be replaced with <CR> <NL>.
 - <Nul> characters are shown on the screen as ^@.  You can enter them with
   "CTRL-V CTRL-@" or "CTRL-V 000" {Vi cannot handle <Nul> characters in the
   file}
-- To insert a <NL> character in the file split up a line.  When writing the
+- To insert a <NL> character in the file split a line.  When writing the
   buffer to a file a <NL> will be written for the <EOL>.
 - Vim normally appends an <EOL> at the end of the file if there is none.
   Setting the 'binary' option prevents this.  If you want to add the final
   <EOL>, set the 'endofline' option.  You can also read the value of this
   option to see if there was an <EOL> for the last line (you cannot see this
   in the text).
@@ -1392,13 +1403,14 @@ to see your text while you are editing i
 ":!filter" or using ":w !command" the text is also not encrypted, this may
 reveal it to others.  The 'viminfo' file is not encrypted.
 
 You could do this to edit very secret text: >
        :set noundofile viminfo=
        :noswapfile edit secrets.txt
-Keep in mind that without a swap file you risk losing your work in a crash.
+Keep in mind that without a swap file you risk loosing your work in the event 
+of a crash or a power failure.
 
 WARNING: If you make a typo when entering the key and then write the file and
 exit, the text will be lost!
 
 The normal way to work with encryption, is to use the ":X" command, which will
 ask you to enter a key.  A following write command will use that key to



-- 
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: pgp85wfZZvDTB.pgp
Description: PGP signature

Reply via email to