sullyj3 / vim-ftplugin-python

1 stars 4 forks source link

Add xmap mappings and improve existing mappings #1

Closed Somelauw closed 8 years ago

Somelauw commented 8 years ago

Add xmap mappings Disable search wraparound (at least for visual mode this makes little sense) Use search() function Use perl regex Replace tabs by spaces ]m and [m end on function definition (first non-whitespace char)

Thanks to strull and Ellesarddan on #vim on freenode for their help on this pull request.

sullyj3 commented 8 years ago

Thanks for the contribution! Unfortunately, your modification to the regex reintroduces the problem I fixed in vim/vim/pull/842. Could you sort that out? Also, I'm not quite sure what you mean by

]m and [m end on function definition (first non-whitespace char)

What behaviour is changed, and what problem does it solve?

Somelauw commented 8 years ago

Thanks for the contribution! Unfortunately, your modification to the regex reintroduces the problem I fixed in vim/vim#842. Could you sort that out?

I had originally based my code on an older version and overlooked this change. I will reintroduce it.

What behaviour is changed, and what problem does it solve?

The problem I was trying to solve, is that when doing the ]m and [m it doesn't position the cursor like this:

|   def

But like this:

   |def

Except that when I just tried your code it didn't behave that way. I am not yet sure why though. The regexes for ]m and [m start with a greedy whitespace match, so I don't get why your jump wouldn't end on a whitespace.

sullyj3 commented 8 years ago

Huh. Good question, I'm now puzzling over that myself. I'm not a regex wizard, and I only added two characters to the end of that particular one, I didn't write it.

sullyj3 commented 8 years ago

When you enter the regex manually it lands on the first whitespace character, so it must be in the function somewhere, rather than the regex itself.

sullyj3 commented 8 years ago

However, when you do :silent! exe '/^\s*\(class\|def\)\>'<cr>, it lands on the d or c... interesting.

sullyj3 commented 8 years ago

Skips the whitespace if you do :/^\s*\(class\|def\)\>``<cr> as well. Very odd.

Somelauw commented 8 years ago

I have readded your modification in https://github.com/vim/vim/pull/842

sullyj3 commented 8 years ago

Thanks! I'll send that off to Bram.