0

I has suffered while customizing my vim editor.

Specifically, I add function which store cursor location.

Below is my .vimrc file.

au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "norm g`\"" |
\ endif

And Error content is below :

au: command not found
-bash: /home/ubuntu/.vimrc: line 24: syntax error near unexpected token `('
-bash: /home/ubuntu/.vimrc: line 24: `\ if line("'\"") > 0 && line("'\"") <= line("$") |'

Could you give me the solution ? Take care of your health during COVID-19. Thanks !


I found solution that change file authority.

chmod +777 ~/.viminfo

.vimsrc file compiled still suffering error.

But function that restore cursor position is working.

Reference : https://askubuntu.com/questions/202075/how-do-i-get-vim-to-remember-the-line-i-was-on-when-i-reopen-a-file

General Grievance
  • 4,555
  • 31
  • 31
  • 45
MVS_beginner
  • 317
  • 2
  • 3
  • 9
  • 2
    Those are not vim errors, those are bash errors. Did you source your .vimrc in vim or in bash? – Randy Morris May 28 '20 at 10:56
  • @RandyMorris Thank you for comment. I edit my .vimrc and run the command like this source ~/.vimrc. And then i met this error. – MVS_beginner May 28 '20 at 11:11
  • 2
    Where do you input `source ~/.vimrc`? This must be at the command line within vim. Enter `vim`, then type `:`. – evnu May 28 '20 at 11:29
  • @evnu Thank tou for comment. But i cannot understand. You means that 1. vi ~/.vimrc 2. Edit Content 3. :source ~/.vimrc. Is it right ? But it isn't changed. – MVS_beginner May 28 '20 at 11:40
  • https://stackoverflow.com/search?q=%5Bvim%5D+bash+syntax+error – phd May 28 '20 at 12:19

1 Answers1

0

You don't need to source .vimrc from the command line, this will be done automatically by vim. Just make sure it's in the right place ($HOME/.vimrc)

Then when you open vim, it will source automatically.

You can view how to debug, where you will see if your file has been sourced in this answer How to see which plugins are making Vim slow?

Hayden
  • 327
  • 3
  • 8