Mercurial > vim
comparison runtime/doc/eval.txt @ 5690:40f18a1c1592 v7.4.191
updated for version 7.4.191
Problem: Escaping a file name for shell commands can't be done without a
function.
Solution: Add the :S file name modifier.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 23 Feb 2014 23:39:13 +0100 |
parents | 1dea14d4c738 |
children | 80e5f9584b02 |
comparison
equal
deleted
inserted
replaced
5689:41fa1a18bc2e | 5690:40f18a1c1592 |
---|---|
5426 Example of use with a |:!| command: > | 5426 Example of use with a |:!| command: > |
5427 :exe '!dir ' . shellescape(expand('<cfile>'), 1) | 5427 :exe '!dir ' . shellescape(expand('<cfile>'), 1) |
5428 < This results in a directory listing for the file under the | 5428 < This results in a directory listing for the file under the |
5429 cursor. Example of use with |system()|: > | 5429 cursor. Example of use with |system()|: > |
5430 :call system("chmod +w -- " . shellescape(expand("%"))) | 5430 :call system("chmod +w -- " . shellescape(expand("%"))) |
5431 < See also |::S|. | |
5431 | 5432 |
5432 | 5433 |
5433 shiftwidth() *shiftwidth()* | 5434 shiftwidth() *shiftwidth()* |
5434 Returns the effective value of 'shiftwidth'. This is the | 5435 Returns the effective value of 'shiftwidth'. This is the |
5435 'shiftwidth' value unless it is zero, in which case it is the | 5436 'shiftwidth' value unless it is zero, in which case it is the |
5908 Get the output of the shell command {expr}. | 5909 Get the output of the shell command {expr}. |
5909 When {input} is given, this string is written to a file and | 5910 When {input} is given, this string is written to a file and |
5910 passed as stdin to the command. The string is written as-is, | 5911 passed as stdin to the command. The string is written as-is, |
5911 you need to take care of using the correct line separators | 5912 you need to take care of using the correct line separators |
5912 yourself. Pipes are not used. | 5913 yourself. Pipes are not used. |
5913 Note: Use |shellescape()| to escape special characters in a | 5914 Note: Use |shellescape()| or |::S| with |expand()| or |
5914 command argument. Newlines in {expr} may cause the command to | 5915 |fnamemodify()| to escape special characters in a command |
5915 fail. The characters in 'shellquote' and 'shellxquote' may | 5916 argument. Newlines in {expr} may cause the command to fail. |
5916 also cause trouble. | 5917 The characters in 'shellquote' and 'shellxquote' may also |
5918 cause trouble. | |
5917 This is not to be used for interactive commands. | 5919 This is not to be used for interactive commands. |
5918 | 5920 |
5919 The result is a String. Example: > | 5921 The result is a String. Example: > |
5920 :let files = system("ls " . shellescape(expand('%:h'))) | 5922 :let files = system("ls " . shellescape(expand('%:h'))) |
5923 :let files = system('ls ' . expand('%:h:S')) | |
5921 | 5924 |
5922 < To make the result more system-independent, the shell output | 5925 < To make the result more system-independent, the shell output |
5923 is filtered to replace <CR> with <NL> for Macintosh, and | 5926 is filtered to replace <CR> with <NL> for Macintosh, and |
5924 <CR><NL> with <NL> for DOS-like systems. | 5927 <CR><NL> with <NL> for DOS-like systems. |
5925 To avoid the string being truncated at a NUL, all NUL | 5928 To avoid the string being truncated at a NUL, all NUL |