Sublime Forum

Fresher ---> webbrowser keymap-bind

#1

################################

this is the py source:

################################

import sublime, sublime_plugin
import webbrowser

class GoogleCommand(sublime_plugin.TextCommand):
def run(self, edit):
url = ‘http://www.google.com.hk/search?ix=hea&sourceid=chrome&ie=UTF-8&q=
sels = self.view.sel()
for sel in sels:
url += self.view.substr(sel)

	webbrowser.open(url)

##################################

this is the sublime-keymap

##################################

{
	"keys":"ctrl+alt+k"], 
	"command": "google"
}

]

#everything is ok when i run view.run_command(‘google’) in console
#but not effective when using key-map
#what`s wrong? can you help me,a fresher …
#Thanks very much

0 Likes

#2

Could it be that when you are typing into the console you are putting single quotes and when you are using the key map you have double quotes? I hope you get this working because this would make things so much easier for HTML which is what I do most.

0 Likes