简体   繁体   English

〜/ .vimrc之后的'ls'bash命令损坏

[英]Broken 'ls' bash command after source ~/.vimrc

I recently sourced my .vimrc that contained this function: 我最近采购了包含以下功能的.vimrc:

 33 function! InsertTabWrapper()
 34   let col = col('.') - 1
 35   if !col || getline('.')[col - 1] !~ '\k'
 36     return "\<tab>"
 37   else
 38     return "\<c-p>"
 39   endif
 40 endfunction
 41 inoremap <tab> <c-r>=InsertTabWrapper()<cr>
 42 inoremap <s-tab> <c-n>

I then from the command line did 然后我从命令行做了

source ~/.vimrc

Now whenever I run 现在只要我跑步

$ls

I see snippets of that function in the output. 我在输出中看到了该功能的摘要。

$ ls
?  else? ??return <c-p
?  endif?endfunction?inoremap <tab> <c-r>=InsertTabWrapper()<cr>?inoremap <s-tab> <c-n>??
Applications
Desktop
Documents

I haven't been able to find anyway to clear this up. 我仍然无法找到任何方法来解决此问题。 Thanks! 谢谢!

Bash can't read Vim syntax, I guess it will trip over the lines ( function , let , if ) and pick up the first > as file IO redirection. Bash无法读取Vim语法,我猜想它将越过代码行( functionletif )并选择第一个>作为文件IO重定向。 And those are actually two files in your directory it has created, with weird characters in their names. 这些实际上是它在您创建的目录中的两个文件,它们的名称中有奇怪的字符。

This is supported by the fact that the output begins after the first > and goes onto a new line after the second > , and those two characters are missing in the output. 输出在第一个>之后开始并在第二个>之后进入新行,并且输出中缺少这两个字符,这证明了这一点。

ie ls is working fine and they really do exist as files. ls工作正常,它们确实以文件形式存在。 Can you delete them? 您可以删除它们吗? Do you have another way to browse files? 您还有另一种浏览文件的方式吗? (a Gui, FileZilla over SFTP, WinSCP, etc?). (一个Gui,SFTP上的FileZilla,WinSCP等?)。 You could try rm *return* and rm *endfunction* , or (carefully) use rm -i * which will prompt y/n to delete each file, and only say y if those files appear. 您可以尝试rm *return*rm *endfunction* ,或者(小心地)使用rm -i * ,这将提示y / n删除每个文件,并且仅在出现这些文件时才说y。

(but I might be wrong and that's not what happened at all. If I try to source your file code, I don't get broken ls or spurious files in the folder). (但是我可能是错的,根本不是这样。如果我尝试获取您的文件代码,则不会在文件夹中出现损坏的ls或伪造的文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM