Toontje Posted December 9, 2019 Posted December 9, 2019 I am still learning so bear with me... I am building a workflow which is taking information from a text document open in vim and pasting it in a browser. For this, in vim, i have to enter a command string like njyt@yt.y$. How do i do this in Alfred? I now have 9 key combo objects with 1 letter each, but there must be a better way to do this. Or not?
vitor Posted December 17, 2019 Posted December 17, 2019 On 12/9/2019 at 1:55 PM, Toontje said: How do i do this in Alfred? I now have 9 key combo objects with 1 letter each, but there must be a better way to do this. Or not? You can send keystrokes with AppleScript, but that’s just the same solution in another way (though it does reduce your nine objects to one). But emulating keystrokes is a poor solution that should only be used as a last resort. The proper way to achieve this would be to code the operation in vim. deanishe 1
Toontje Posted February 1, 2020 Author Posted February 1, 2020 How about if i want to send a URL to an already open browser? Or a string to a text input box in an application? That's the same use case, IMHO.
deanishe Posted February 1, 2020 Posted February 1, 2020 1 hour ago, Toontje said: That's the same use case, IMHO. Only superficially. What matters is which tools are available in each case, and simulating keypresses via AppleScript is, generally speaking, the worst tool for the job. If the application offers a proper API to achieve what it is you're trying to do, that is always a better, more reliable option. And vim does. Why are you firing 9 different keystrokes at vim when you can use something like nmap <F4> njyt@yt.y$ in your vimrc to map your command to a single keystroke?
Toontje Posted February 1, 2020 Author Posted February 1, 2020 16 minutes ago, deanishe said: If the application offers a proper API to achieve what it is you're trying to do, that is always a better, more reliable option. And vim does. Many applications don't. Please, enlighten me on the idea why it is possible to send one keystroke from Alfred, but not multiple (a string).
deanishe Posted February 1, 2020 Posted February 1, 2020 2 minutes ago, Toontje said: Please, enlighten me on the idea why it is possible to send one keystroke from Alfred, but not multiple (a string). I don't know what you mean. You can send as many keystrokes as you want. It's just very cumbersome because Alfred isn't really designed for sending long sequences of keystrokes. Vim's API is, which is why it's a better choice. 4 minutes ago, Toontje said: Many applications don't. And in those cases, you don't have much choice but to simulate keypresses. This is not one of those cases.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now