简体   繁体   English

.vimrc“设置pastetoggle = <F2> ”在运行“源.vimrc”时给出错误

[英].vimrc “set pastetoggle=<F2>” giving error while running “source .vimrc”

I'm using CentOS 7 and added set pastetoggle=<F2> in .vimrc to toggle the auto-indentation. 我正在使用CentOS 7,并在.vimrc添加了set pastetoggle=<F2>来切换自动缩进。 While running source .vimrc , it is throwing the below error 运行source .vimrc ,它抛出以下错误

-bash: .vimrc: line 4: syntax error near unexpected token `newline'
-bash: .vimrc: line 4: `set pastetoggle=<F2>' 

Here's my .vimrc file for reference 这是我的.vimrc文件供参考

set ai
set tabstop=2
set expandtab
set pastetoggle=<F2>

Please help me and let me know, how to resolve the issue? 请帮助我,让我知道,如何解决该问题?

You are trying to source a vim config file in your shell, which would indeed throw an error. 您试图在shell中获取vim配置文件,这确实会引发错误。 If you are trying to update the vim config on the go, then after updating your ~/.vimrc file(assuming you are using vim to edit the vimrc file) , from vim open the command line mode by pressing : and type in source % (where % denotes current file). 如果您要在旅途中尝试更新vim配置,则在更新〜/ .vimrc文件(假设您正在使用vim编辑vimrc文件)之后,从vim中通过按打开命令行模式,然后输入源% (其中%表示当前文件)。 Then your new config gets updated on the go. 然后,您的新配置会随时更新。

If you're lazy like me then bind it to a key for sourcing, like so in normal mode : 如果您像我一样懒惰,那么可以将其绑定到用于采购的密钥,例如在正常模式下:

nnoremap <leader>so :w<cr>:source %<cr>

If you are using some other text editor to edit ~/.vimrc, then save and exit the file, then open a new instance of vim and your changes get updated automatically. 如果使用其他文本编辑器编辑〜/ .vimrc,然后保存并退出文件,然后打开新的vim实例,则更改将自动更新。

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

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