junegunn / limelight.vim

:flashlight: All the world's indeed a stage and we are merely players
MIT License
2.36k stars 54 forks source link

Don't move the cursor to beginning of line on deactivating limelight #60

Closed ohcibi closed 4 years ago

ohcibi commented 4 years ago

I was using Limelight automatically in insert mode but not in normal mode using the following snippet in my vimrc:

augroup writing
  au!

  autocmd! InsertEnter * Limelight
  autocmd! InsertLeave * Limelight!
augroup END

This works pretty well specifically for coding since you can still see the syntax highlighting of the entire file while in normal mode (which one is usually in while reading the code) but are not distracted from all that noise while writing. The only problem was that because of how the range was passed to the execute function my cursor was moving to the beginning of the line whenever I exited insert mode. Today I was annoyed enough of that to do something about it :laughing:.

I made the Limelight command pass the range as parameters to the execute function which removes that effect while Limelightening a range still works. I'm no expert in vim script so please tell me if there is a better way to do this or if I have forgotten any edge case and I'll fix it.

narajaon commented 4 years ago

OMG I was about to uninstall this plugin because of this behaviour. You are a life saver sir.

junegunn commented 4 years ago

Thanks!