Any text editors for Mac with hotkey PASTE of pre-defined text for faster coding? - macos

Coding PHP on a Mac using TextEdit. It's always annoying to have to type the same lines of code that I use over and over (Ex: MyClass::myLocalizedString('Hello');).
Anyone know of a useful editor for Mac that can save me time by allowing me to predefine a string and bind it to a hotkey combination?
Ex: Cmd+1 pastes the text MyClass::myLocalizedString('');

Tincta Pro also has a code-snippets feature with shortcut expansion.
(Disclaimer: I'm the developer of Tincta)

I think there are plenty of choises. For instance, you can use Keyboard Maestro to create a hotkey or use TextExpander for short snippet. I think you might be able to create this with Quicksilver too, but for this I'm not sure.

Related

is it possible to map Vim key bindings for windows, just like vimium for chrome

is it possible to map Vim key bindings for windows? just like vimium for chrome. I don't like the mouse sometimes.
using vimium, I can press 'f' to generate 'names' for the link, and just press the name to open the link, it's awesome!
This is an AutoHotKey script that implements some of the vim functions in all applications.
Also LabelControl provides some label support, like vimium, but it's not always that useful.
you can use hunt-n-peck .
you should download binaries from continous integration artifacts.
this is the hunt-n-peck binaries zip link HuntAndPeck taken from repository's continuous integration artifacts.
I don't know about any existing tool, but macro tools like AutoHotkey allow to implement that. For a purely modal solution like in Vim, you'd need to save the mode state (and probably also indicate it somehow), which is difficult. Creating vim like functionality with autohotkey ahk outlines a solution (for navigation) that relies on another simultaneously pressed key instead.
To answer the stated question: Yes, and there exists several, but they have limitations. The best way that I know of is using AutoHotkey, which can be used to add several of Vim's features.
Due to how Vim commands work, it is only partially possible, as implemented in several forms. For several examples you can search for e.g. "autohotkey vim".

Windows Macro + Hot Key - Paste Without Formatting

Not sure if this appropriate to put as a question or not? It's sort of a scripting question I think. Just down vote me if not :p
Basically, what I'm looking for is a way to push a windows hotkey and have whatever text is in the clipboard be stripped of formatting. An example of what the macro could do:
I push (whatever hotkey combo here)
open notepad.exe
Paste to notepad from clipboard
Select all text in notepad
Copy/Cut all text from notepad
Close notepad
I'm just wondering if someone has done something like this before, or knows how it could be accomplished. I think this could be a huge time-saver for almost anyone. I find myself doing this all the time when cutting and pasting between different office applications, etc.
Have you heard of Puretext, it appears to do what you're looking for:
http://www.stevemiller.net/puretext/
Instead of emulating hotkeys to control Notepad, you can write code to implement what Notepad implements when it gets text from the clipboard: i.e. use the clipboard API to get the clipboard contents as unformatted text.
Try AutoHotKey to make a tiny and easy script to do what you want.
You will find a powerful windows interface macro programing tool.

Adjusting keyboard shortcuts on Windows

How to change default shortcuts?
For example, I want to try Caps+S instead of Ctrl+C.
Autohotkey is probably what you want. There are some instructions for remapping keys.
You might also be interested in Ctrl2Cap

Safe keyboard shortcut for activating code completion style functionality in Mac OS X browsers

I'm building some code completion style text expansion functionality for text areas and inputs in a web application. I'm trying to work out a safe keyboard shortcut for invoking the completion proposals for browsers running on Mac OS X.
I've eliminated some potential candidates:
Command + Space - activates the Spotlight search field
Control + Space - activates the context menu in Firefox
Esc - cancels any background XMLHttpRequests in Firefox
That leaves Option + Space. I'm aware that may conflict with tools like Ubiquity, but that's something we don't expect our audience to be using.
Are there any conflicts I may have missed with Option+Space? Or do you have a better idea for a keyboard shortcut, and why?
A lot of Mac OS X apps use Option + Esc to do code completion or code hints.
Some kind of tab shortcut sounds like the best and most intuitive approach - users should be used to the 'type-tab-type-tab' workflow - maybe combine it with a modifier if it only wants to be optional.
As I recall, Visual Studio and TextMate both use tab to code-complete. In Visual Studio an intellisense menu pops up as you start typing and tab acts as the selection confirmation.
In TextMate, you start typing part of a command then hit tab to activate said command's associated "bundle". The associated bundle typically generates a code snippet and fills in any dynamic parts of the snippet as you type.
Come to think of it, most command lines work this way as well, auto-completing file names and paths when tab is pressed after typing a few characters.
EDIT: You say tabs are needed for field switching in a web interface, but you may want to try intercepting the keyboard event in the textfield, and check if they're started typing a macro. If they have, auto-complete and swallow the key by returning false; if not, simply let the command bubble through.
I discussed these ideas with our design team. One of them suggested using Control + Enter, which is what we decided to go with. This causes forms that only contain a single input field to automatically submit in Firefox, but we deal with that by preventing the default action caused by the event.
I re-assigned the Spotlight command to Command + Shift + Space. This is easily done via Prefrences.App

Is there a Firefox add-on to use vim to edit textboxes?

or "How do I answer questions on SO in Firefox using gVim inside the textboxes?"
It's All Text!
From the extension page:
At the bottom right corner of any edit
box, a little edit button will appear.
Click it. If this is the first time
you've used "It's All Text!" then you
will be asked to set your preferences,
most importantly the editor.
The web page will pop up in your
selected editor. When you save it,
it'll refresh in the web page. Wait
for the magic yellow glow that means
that the radiation has taken effect!
Vimperator makes Firefox act very much like VIM:
Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.
Once you have the cursor in a text box, hit Ctrl-I to open in your editor, which defaults to gvim.
The current answers don't work anymore now that Mozilla removed XUL in favour of WebExtensions. With recent firefox versions, there are the following options (sorted in descending order by the current popularity on addons.mozilla.org).
GhostText provides instant synchronization between editor and textbox via editor-specific plugins. The project is on github and the vim extension is written in Tcl.
withExEditor is cross-platform but requires a native application written in node.js. In addition to editing text fields it also allows viewing the source of the page, MathML, SVG and the current selection. The project on github and the native node.js application
Textern requires a (currently) Linux-only native application written in Python. Synchronizes the content of the text field while you type in the editor. The extension and the native app can be found on github
Tridactyl is probably what you're looking for nowadays.
It's the spiritual successor to the likes of Pentadactyl and Vimperator, which are not available for the current version of Firefox.
If you want something more like It's All Text, where the editing area appears right on top of the browser text area rather than launching an editor window, and you're willing to use Neovim, check out firenvim.
It's All Text! will let you use whatever editor you want. To use vim with it, you'll need a small shell script to open it in a terminal:
#!/bin/sh
exec xterm -e /usr/bin/vim "$#"
If you have GVim, you won't need the shell, script, obviously.
ViewSourceWith is another addon worth lookng at. It supports more than just edit boxes and text. For example, you can configure it to open images in the GIMP.
Another feature that I find useful is that it can pop-up a dialog box that shows all the js and css scripts used on the page. You can then choose to view/edit file in your preferred editor.
For answering questions on SO, you may also want to get the Vim Markdown Syntax file
The "It's all Text" extension, perhaps?
http://addons.mozilla.org/en-US/firefox/addon/4125
If you use vimperator and have the markdown syntax file installed, a useful line for your .vimperatorrc is:
au LocationChange .* :set editor="gvim -f"
au LocationChange stackoverflow\.com :set editor="gvim -f -c 'set ft=mkd'"
This will tell vim to do syntax highlighting for markdown when you are on stackoverflow.com, but not when you are any other site. There are similar hacks for wikipedia/mediawiki etc. Enjoy :)
One way to do this is to use the vimperator extension - of course, that does a lot more than what you're looking for.
At the time of writing it is experimental, but the jV extension looks good. To quote from the page:
This extension makes all html textareas into a very stripped-down version of Vi[m]. It's modal, supports infinite undo, has register support, search, visual mode, and various movement and editing commands.
When using Vimperator in Windows (I am using Vista) you may need to double-escape the path to gvim.exe to use it as the external editor. Single escaping did not work for me as Vimperator unescapes it twice. Eg:
:set editor="C:\\\\Program\\ Files\\ (x86)\\\\Vim\\\\vim72\\\\gvim.exe" -f
Then while in a text box you use Ctrl+I and it will open gvim for editing. When you save and exit it will update the text box.
There is an experimental way to directly embed the real vim in firefox using embedded editor - though it requires mozplugger and will only work on Linux.
Try out the wasavi extension. You might want to check out the all versions page to make sure you try out the latest version. (Copy of this answer.)
You can also use the ViewSourceWith addon to achieve the same. Just right-click on any text input and you can edit it using Vim.
As said by others,
as a Vi/(g)Vim user you'll probably want to look at the Vimperator addon, which also provides the what you ask:
inside a textbox, hit <C-i> to launch the external editor.
(can be defined in _vimperatorrc: set editor=gvim -f )
A hint for Mac users: if you want to use "It's all text" with vim, the easiest way is to use http://code.google.com/p/macvim/ . Point "It's all text" to the mvim script that's provided along with the .app (you can place this script anywhere, I choose /usr/bin/ so that I can load mvim from the command line)
Pterosaur is a Firefox plugin that allows you to use Vim in all input fields. It uses an actual Vim process in the background so it has all the functionality you expect, including reading your .vimrc configuration and your plugins.
With Firefox-57 on Linux, I installed textern https://addons.mozilla.org/en-US/firefox/addon/textern/, and found it to be a suitable replacement for ViewSourceWith for editing text boxes.

Resources