简体   繁体   中英

.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. While running source .vimrc , it is throwing the below error

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

Here's my .vimrc file for reference

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. 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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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