amoffat / snake

Full Python Scripting in Vim
1.41k stars 56 forks source link

get_word fails when vim is using OS X clipboard via `set clipboard=unnamed` #10

Closed smartt closed 9 years ago

smartt commented 9 years ago

set clipboard=unnamed makes vim play nice with OS X; however, it changes yank behavior such that vim isn't using the registers that get_register expects. I haven't come up with an alternative yet, so I'm hoping someone else has an idea (and hence, the ticket.)

amoffat commented 9 years ago

ah, so the special yank register isn't being used? It sounds like it could be a simple fix. Try changing this line https://github.com/amoffat/snake/blob/master/plugin/snake/__init__.py#L337 to be keys('"ayiw') and the following line to be get_register("a") and see if that works

smartt commented 9 years ago

Perhaps I was sniffing up the wrong tree. This fixes it for me (inside replace_word):

@@ -346,7 +346,7 @@
 def replace_word(rep):
     """ replaces the word under the cursor with rep """
     set_register("0", rep)
-    keys("viwp")
+    keys('viw"0p')

 @preserve_state()
 def get_in_quotes():
amoffat commented 9 years ago

Great, so a similar change (explicitly setting "0) in get_word works for you as well? I don't have OSX to test

smartt commented 9 years ago

Working on OS X now. Thanks!