Editing e-mails in your browser using (g)vim - vim

Long ago, I was using the hack given in http://vim.wikia.com/wiki/VimTip805 . This hack allowed me to edit any active window frame using gvim. For instance, I was able to edit my gmail replies using gvim.
Unfortunately, the hack does not work to me any more. Is there any other way to achieve the same? Or at least to achieve the same using some concrete browser (for example, firefox)?

Google Chrome
you can use GhostText with running server vim-ghost. Its not ideal, but allow to interactively use external editor (text is automatically copied to a web textarea element each return to normal mode).
Vim-ghost is written in tcl so you need install tcl.
In my case I have tcl installed but without standard library tcllib. So I found lacking packages in tcllib (tcllib/module/sha1 and tcllib/module/json) and copy them to a folder listed in tcl path (the first result of echo $tcl_pkgPath). More info: man pkg_mkIndex or here.
Of course vim-ghost server must be run (eg. in autorun script):
~/.ghost-text-server.tcl &
You can also like Vimium to navigate through web using links, tabs, j, gg and many vim-like features.

You should check vimperator( pentadactyl, which is a fork of vimperator). They offer the ability to edit text boxes, but also offers several additional functions that allow you to control firefox in a similar way to Vim.
If you prefer Vim only for edit text boxes you could try the firefox plugin "It's all text", as mentioned by Kent.

I'd recommend It's All Text plugin for Firefox.

Related

Using console as tab

I have several cpp source files in tabs in vim. I would like to have another tab with command prompt in order to run make. I open net tab , run sh and now I have console. But how to move from this console to other tabs? If I press ctrl+page up I have garbage in console and no tab change. How to move to another text tab when staying in console tab?
As I said, vim 8 or neovim both have an terminal emulator in it.
Since you are using vim 7 here are some other ways:
Tmux as #wizzup mentioned is perfect for this use-case. I think it is the most used Terminal-Multiplexer and extremly mighty. It is complex in comparison but since you are using vim, a steep learning curve should not be a killer point. However there are a few cavehats but you will find thousands of articles to solve them.
GNU Screen is an alternative to tmux, I have no experience with it, but should be usable pretty good with vim too.
With them you can use something like this Plugin which allows you to use the terminal in vim itself. However I haven't tested it but it seems to be rather groomed.

Terminal emulator with good plugin support?

Is there any good linux terminal emulator that supports plugins?
What I am after:
Open source
Being able to highlight and color text fragments
Being able to tweak the GUI (create popup windows, present menus and buttons integrated with the text display -- for instance to open the man page in a floating window when clicking on a command name)
Being able to write plugins in a number of languages (Ruby preferred)
Cheers!
All that I found:
termit - extensible via lua
rxvt-unicode - extensible via perl

Programmatically add keyboard shortcut to Mac System Preferences

If I go to System Preferences, Keyboard, Keyboard Shortcuts, then Application Shortcuts, I can define custom shortcuts to be used on a Mac.
Any way to access this functionality via Applescript?
The shortcuts are stored in NSUserKeyEquivalents dictionaries in ~/Library/Preferences/.GlobalPreferences.plist and the property lists of applications.
defaults write -g NSUserKeyEquivalents -dict-add Duplicate '~#d' Minimize '\0'
defaults write com.apple.finder NSUserKeyEquivalents '{"Show Package Contents"="#\r";}'
The shortcut format is described in the Cocoa Text System article.
System Preferences isn't scriptable with Applescript natively, you have to interact with it by GUI Scripting. GUI Scripting is really a last resort that allows you to interact with controls by explicitly declaring and calling them, and it doesn't take much to throw off a GUI script. It is difficult to implement even for experienced Applescript programmers. You'll find a few introductory tutorials out there in the web, but not much else.
The internals of the Mac OS are quickly becoming a lost art. Run the following in a shell, or run via shell in Applescript:
defaults write com.google.Chrome NSUserKeyEquivalents '{ "Search the Web…" = "#k"; }'
Also good to know: shortcuts for Services are in the pbs.plist, and they're stored using a different property than the NSUserKeyEquivalents.
There's info on how to write a basic script to change/add shortcuts for Services here:
Set Services keyboard shortcut via script OSX
This was the method I found the simplest, and it worked well for me (macOS 10.12.6 Sierra):
You can also use PlistBuddy and defaults:
/usr/libexec/PlistBuddy -c 'Delete NSServicesStatus:"(null) - test2 -
runWorkflowAsService"' ~/Library/Preferences/pbs.plist
2>/dev/null;defaults write pbs NSServicesStatus -dict-add '"(null) -
test2 - runWorkflowAsService"' '{key_equivalent = "^~#2";}'
The PlistBuddy command is not needed if there is not an existing entry
for the service. Replace test2 with the name of the service. Quit and
reopen applications to apply the changes.
^~#2 is control-option-command-2. See
http://osxnotes.net/keybindings.html.
And in case this might help those who are a bit less familiar with writing/executing scripts on macOS, I saved the script as a shell script (.sh extension), and ran it from Terminal using the following commannd:
sh "/path/to/script/scriptfile.sh"
I have written an AppleScript library to programmatically add Global & Application shortcuts. It took a tremendous amount of effort to work around the various quirks in how macOS implements shortcuts.
Version 1.0 is available here:
https://forum.latenightsw.com/t/setting-other-applications-keyboard-shortcuts-using-nsuserdefaults-defaults-not-updating/3537/5
I will be making some minor API additions & changes when I find the time, and will post the source code here in full at that time. Note that as mentioned above, Services shortcuts are stored using a completely different system & are not handled here.

Interface texshop with vim

Any advice on how you would interface texshop on mac osx with vim? I'm using vim quite a lot lately for coding. I find myself now trying to use vim-commands (replace, search, pattern matching, move, etc) when writing documents for latex with texshop and they obviously don't work. However, I don't want to leave texshop altogether, because it has some pretty nice tools I use very often (maybe the most important one is the ability to click the compliled .pdf file while pressing the CMD key on my macbook to jump immediately to the corresponding place in the .tex file).
Thanks in advance!
Can't really help with the question but if you want to use vim I would highly recommend vim-latex suite. It has a lot of mappings and other latex goodness including completion of references/citations (it loads them from the bib file and gives prompts based on what you've already typed). Also it supports pdfsync forward/backward searching - I use that with Skim. There is some information here on how to get that working (and see other posts on that blog).
Are there any other texshop features you would like to reproduce in Vim?

I want to use VI-like commands in Web Browser?

I love VI and I'm looking for a plugin of some sort that would allow me to input text in my browser (preferably Firefox or Chrome) using VI commands. It would save me an immense amount of time and at the same time when writing long emails. Can anyone think of any plugins that would allow me to do this? I was hopeful with Vimperator (https://addons.mozilla.org/en-US/firefox/addon/4891) but after installing it, I realized that it didn't do the one VI think I wanted to do: create or edit a text box with VI commands. It just allowed me to do Browser commands and scrolling in VI-style.
since you have installed Vimperator , you can try this :
se
editor=”YOUR-GVIM-PATH/vim72/gvim.exe
-f”
Press Ctrl + i to call gvim to deal with the text you want to edit.
I've had great luck with itsAllText firefox extension. Probably not as smooth as your dream, but it works very well in practice.
https://addons.mozilla.org/en-US/firefox/addon/4125
I've been using the Mozex extension for Firefox for years.
http://mozex.mozdev.org/
Once installed, on the "Textarea" tab, assign a hot-key and enter the command to run. For example:
gnome-terminal -e "/usr/bin/vim %t"
When the hot-key is pressed, Mozex will create a temporary file and replace the "%t" above with its name.
If there's more than one text area on a page it will allow you to pick which one you want to edit.
Mozex provides a lot more functionality than just text area editing. If you want to "view source" with Vim, you can do that too.
I've used jV for a while on firefox. It works even with newer versions that the extension doesn't officially claim to support. The dev says they are working on a chrome version.
Currently the Chrome Extensions API is fairly simple; I simply don't think that there are currently enough API hooks into the browser to be able to support something like this.
You might want to check out the confusingly-named Conkeror browser (not the same as Konqueror in Linux), which is best described as the love child of VI and Firefox. It's like VI with the Gecko rendering engine (I think).

Resources