mscoutermarsh / dotfiles

my Vim/Tmux config :muscle::zap:
https://mikecoutermarsh.com/boston-vim-learning-vim-in-a-week/
Other
765 stars 181 forks source link

Addition to the removal of trailing whitespaces #4

Closed hallzy closed 9 years ago

hallzy commented 9 years ago

By putting the substitution that you had before into this function, when the function is called it will also save your current cursor position before the substitution is made. This way, after a substitution is made on a save your cursor will not be at the bottom of the file where the last substitution was made.

I also have:

au BufWritePre * :call...

instead of:

au BufWritePre *.rb :call...

Because I like to remove trailing whitespace from all files I save with vim, not just ruby files. But if you prefer to only have that take effect in ruby files then that line can be changed to reflect that.

hallzy commented 9 years ago

ah yes... line 243 should be

au BufWritePre * :call <SID>RemoveTrailingWhitespaces()

in my .vimrc I have the function called MyFormattingSubs because I have some substitutions that also make formatting changes such as, if I have:

if(x){

it would be changed to if (x) {

So yes, that was a copy paste error. I can fix it later if you want, or you can fix it... either way.

hallzy commented 9 years ago

The pull request has been updated with the fixed typo.

mscoutermarsh commented 9 years ago

hey @hallzy thanks! looks like there is a small bug tho. Just tried it out.

Error detected while processing function <SNR>2_RemoveTrailingWhitespaces:
E121: Undefined variable: _s
hallzy commented 9 years ago

Wow I am on a roll. It was another copy/paste error. Just fixed it.

mscoutermarsh commented 9 years ago

:) awesome. Will merge back in soon

hallzy commented 9 years ago

Just noticed that the change is not part of this pull request. Does it need to be reopened to find the new change?

mscoutermarsh commented 9 years ago

I think you need to open a new PR.