Vimscript允许多行字符串吗?

Vimscript允许多行字符串吗?,vim,Vim,Vimscript允许多行字符串吗 python和ruby命令允许以下格式::pythonVimscript确实允许通过使用反斜杠开始下一行来继续上一行,但这并不像在ruby、PHP或Bash中找到的herdoc字符串那样方便 let g:myLongString='A string \ that has a lot of lines \ each beginning with a \ backslash to continue the previous one \ and wh

Vimscript允许多行字符串吗


python和ruby命令允许以下格式:
:pythonVimscript确实允许通过使用反斜杠开始下一行来继续上一行,但这并不像在ruby、PHP或Bash中找到的herdoc字符串那样方便

let g:myLongString='A string
\ that has a lot of lines
\ each beginning with a 
\ backslash to continue the previous one
       \ and whitespace before the backslash
       \ is ignored'
查看。

Vimscript多行字符串,点运算符: 枚举赋值并包括上一个赋值,可以在多行上进行合并

let foo = "bar" 
let foo = foo . 123 
echom foo                      "prints: bar123 
使用复合字符串连接运算符点等于:

let foo = "bar" 
let foo .= 123 
echom foo                      "prints: bar123
let foo = ["I'm", 'bat', 'man', 11 ][0:4] 
echo join(foo)                                   "prints: I'm bat man 11 
function! myblockcomment() 
    (*&   So we back in the club 
    //    Get that bodies rocking 
    !#@   from side to side, side side to side. 
    !@#$   =    %^&&*()+
endfunction 
列出您的字符串和数字,并将它们连接起来:

let foo = "bar" 
let foo .= 123 
echom foo                      "prints: bar123
let foo = ["I'm", 'bat', 'man', 11 ][0:4] 
echo join(foo)                                   "prints: I'm bat man 11 
function! myblockcomment() 
    (*&   So we back in the club 
    //    Get that bodies rocking 
    !#@   from side to side, side side to side. 
    !@#$   =    %^&&*()+
endfunction 
与上面相同,但与数组切片连接

let foo = ["I'm", 'bat', 'man', [ "i'm", "a", "mario" ] ] 
echo join(foo[0:2]) . " " . join(foo[3]) 
"prints: I'm bat man i'm a mario
行开头的反斜杠允许行继续

let foo = "I don't think mazer 
  \ intends for us to find 
  \ a diplomatic solution" 
echom foo 

let foo = 'Keep falling,  
  \ let the "grav hammer" and environment 
  \ do the work' 
echom foo 
印刷品:

I don't think mazer intends for us to find a diplomatic solution
Keep falling, let the "grav hammer" and environment do the work
在函数中隐藏您的密文和最古老的大部头:因此:

let foo = "bar" 
let foo .= 123 
echom foo                      "prints: bar123
let foo = ["I'm", 'bat', 'man', 11 ][0:4] 
echo join(foo)                                   "prints: I'm bat man 11 
function! myblockcomment() 
    (*&   So we back in the club 
    //    Get that bodies rocking 
    !#@   from side to side, side side to side. 
    !@#$   =    %^&&*()+
endfunction 
自由格式文本的内存位置是它位于磁盘上的文件。函数永远不会运行,否则解释器会呕吐,所以在使用vim反射获得
myblockcomment()
的实现之前,请先执行该函数,然后执行您想要的任何操作。除非让人眼花缭乱,否则不要这样做。

您不能使用