Is there a programmer's text editor for OS X with narrowing? - macos

I think the title is essentially self-explanatory except for a necessary clarification and caveat:
Clarification
I'm not entirely sure if 'narrowing' is the universal term for the feature I'm referring to. What I mean is something like Emacs' 'narrow buffer', ie. the ability to select a region and quickly narrow the editor window to show only that region, and then after some edits to be able to quickly zoom out to see/edit the full file again. It's a feature I like, and find far more useful than code folding.
Caveat
Of course the answer is 'yes -- (X)Emacs' (and possibly vim?). But I'm looking for something other than vim or Emacs; almost certainly a more GUIsh one (think Textmate, TextWrangler etc).

My researches seem to suggest that the straightest answer is just 'no'. I haven't been able to find an editor that runs on OS X that supports narrowing, other than emacs.
I have however figured out a workaround that might be of interest for some scenarios, which is to use Hog Bay Software's QuickCursor in conjunction with one or more editors.
For example, I've tried setting up QuickCursor to fire up TextMate. So now when working in XCode, I can select the text I want to narrow to, hit the global hotkey I have set up, and the selected text pops up in a TextMate window. That can be edited, then a save and dismiss window pops the edited text back in XCode.
This also works if you're just working in TextMate (or, I imagine, one of the other editors that QuickCursor can control); ie. you can select select test in the editor, trigger QuickCursor to open the selected text in a new window, and later pop that text back to the original window.

I'm guessing this is not what you want, but you didn't specifically say so: Aquamacs? It's an emacsen with good integration with OS X (cut, paste, menus, toolbars, etc).

Related

Keyboard shortcut to select editor tab by number in XCode

Is there a way to select a tab by ordinal number - like in browsers? In particular something like Control-1/Control-2 or Alt-1/Alt-2 to select one of the two tabs presently displayed.
Note that even the command-{ and command-} are not working for me.
Therefore even the less preferable approach of cycling through the tabs - as shown in a couple of questions such as this one https://apple.stackexchange.com/questions/85461/programmer-new-to-apple-how-to-efficiently-switch-between-files-in-xcode - do not work. So presently there is no way to switch tabs except by physically clicking on them.
A quite acceptable alternative would be a keyboard driven quick-list like Command-E in JetBrains IDE's (intellij, pycharm, AppCode, etc)
This is not an answer to your real question, which is a great idea — the answer is no, there isn't. (File an enhancement with Apple...!)
However: The keyboard shortcut for toggling to the next tab is Control-Tab, which I find quite easy to remember.
Also note that all keyboard shortcuts are user-configurable.

Keyboard shortcut for a repetitive sentence

I'm currently saving 200/300 PDFs a day (work related), they all have a sentence in that's the same, I'm unable to use Ctrl C/V as I have to copy other parts before saving.
Is there a way for me to have a keyboard shortcut that puts the sentence in for me when saving the file?
(Windows 7 and limited admin access)
Many Thanks,
L
You could use a Macro editor which records keystrokes and repeats them.
This one is a free portable example (doesn't require an installation).
https://portableapps.com/apps/utilities/tinytask_portable
On windows 7 you can only have one Item in the Copy&Paste Memory, so there is no other easy way than to simulate keyboard input. You can also "Drag and Drop" the sentence from somewhere else (like a website) by selecting it and then clicking on it and dragging it into the Document.
Maybe that works better for you.
I'm not sure I've understood completely your problem, but in all likelihood a clipboard manager would suit your case.
They don't (usually) allow you to have a sentence inserted automatically before saving, but they let you save many instances of "clippings" and paste them conveniently.
There are a lot of them, I personally like Clip and used also ClipX and Ditto.
Many of these clipboard managers include features to associate a specific hot key to insert a specific snippet of text.
There also programs that are focused specifically on that HotKey -> specific snippet functionality, or that include it among others.
Also, if clarified what software you're using to do these "pdf savings", it would help (it's possible that it does include facilities to include a sentence before saving).
And in any case you can almost for sure do what you want with a macro/scripting utility such as AutoHotKey (but it would usually be pretty complex if you're not already familiar with it).

How to make xCode "act" as the most normal editors?

I wonder, why doesn't xCode "act" as a normal editor? For example, when I press Ctrl+X, I'd like the current line to be copied-cut. When I press Shift+Tab I'd like the current selection to be shifted to the left, etc. That's the stuff most editors do by default.
How to make it do that?
Take a look at Preferences -> Key Bindings. Here you get a list of actions and their keyboard shortcuts - and you can change those keyboard shortcuts!
It's quite amazing how many actions there are, including a great number of familiar Emacs actions such as mark and yank. Many of them have no corresponding menu item; many of them have no keyboard shortcut by default. Some of them may be the things you are looking for, and all you need to do is change the shortcut if you don't like it. It is very possible that you'll find at least some bindings that you can use to make Xcode behave in a more familiar way.

Are these NotePad++ features available in TextMate?

I'm a NotePad++ user, new to TextMate.
There are some features that I really like in NP++ but couldn't figure out if TextMate support them.
Double click on a variable and have all instances highlighted
View 2 text windows side by side
Drag a file onto another opened Window
For this one, I don't know how to generate a screenshot ;-p. Basically, you can drag a file from Windows Explorer and drop it into NP++ to have it opened.
A lot of long time TextMate users are leaving TextMate land, actually. So, I'm not sure it's the right time to move to TextMate.
Emacs and Vim both do what you want and more. If you can afford the learning curve it's definitely worth it.
As for your question:
View 2 text windows side by side
You can have two or more windows for the same document. Assuming you are in a "project" right-click your file in the drawer and choose Open "foo.ext" in New Window. The two "views" contents are more or less in sync but doing cool things like columnar editing tends to break the syncing.
Due to how Mac OS X manages windows, the new window will probably be too large/too small and/or placed in a less than useful place. I use ShiftIt system wide to manage my windows and in such a case have them the same size side by side.
Double click on a variable and have all instances highlighted
What do you use this for? Is this visual highlight or non-contiguous selection?
Type ctrlw to select the word, then ⌘e to make the word your search term, then ⇧⌘f or Edit > Find > Find in Project… It will show all instances of the search term in another window. You can then "jump" to any occurence and do whatever you want.
If you only want to jump from occurence to occurence, select the word then type ⌘e then ⌘g to jump to the next occurence.
Another way is to type ctrls, a little text field appears at the bottom of your window where you can type a word and see its first occurence selected in real time. Repeatly typing ctrls will cycle through the occurences.
Drag a file onto another opened Window
You can drag & drop a file on TextMate's icon in the Dock. You can also right-click the file and choose Open with TextMate *or Open with…*. If you are in a "project" you can right-click and choose Add Existing Files…. Opening multiple files in TextMate will automatically create a "project" for you.
View 2 text windows side by side
I just tried this and it doesn't seem to recognize this functionality. the only time any sort of "add" icon came up was when I dragged the file into an open document and then released, but that resulted in adding the contents of the file into the document.
I just did a quick google search for "textmate split view" and it still doesn't seem to be supported according to some of the answers i found (one from macromates wiki).
Double click on a variable and have all instances highlighted
This also doesn't seem to be supported. This post suggests using the command + f (find), put the word into find, then command + g to jump to the next instance of that word.
There are definitely some things that can be added to textmate to make it more robust. If you are looking for something similar and are on a windows machine, you should check out e text editor. I loved that editor when I was working on a windows machine - split view is supported, but not sure about the highlighting. One thing that e also beats out textmate is the real time regular expression highlighting.

Reuse Edit Control as Command Window

This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such:
Name of favorite porn star:
The user should be able to enter text after the prompt like such:
Name of favorite porn star: Raven Riley
But I need to prevent the user from moving the cursor into the prompt area. Users should also be prevented from backspacing into the prompt in order to prevent the following:
Rrraven Rrrileeey Ruuuulez!!! Name of favorite porn star:
Also need to control text selection and so on. And finally, I should have no problem retrieving only the text the user entered (minus prompt text).
Will it be better to create my own window class from scratch (i.e inherit from CWnd) or should I reuse the Windows EDIT control (i.e. inherit from CEdit)?
A similar command window can be seen in AutoCAD and Visual Studio (in debug mode).
I think you'd be better off creating a subclass of CEdit and limiting filtering key-presses. I suppose the hard part is not letting the user move the caret to the prompt area, but you can probably write some code to make sure the caret always get sent back to where it belongs (the input part).
Anyway, if you really, really want to implement your own control (it's not that difficult after all) I recommend you read Jacob Navia's "technical documentation" on how he built the LCC compiler and environment. Actually, it seems the docs are not online anymore, but I'm sure you can get them through his e-mail (jacob#jacob.remcomp.fr).
Edit: I liked your previous example better. Keep it classy, LOL :)
I had a very similar requirement and did exactly what davidg suggested; subclassed a edit control and filtered key presses. This was actually using Qt not MFC but the principle will be exactly the same.
You need to remember to filter keys such as home as well as left and backspace. I just checked to see if the move would move the caret into the prompt and if it did ignored the keypress.
Another thing to watch for is pasting multiline text, you will have to choose whether to just paste the first line or all lines, adding the prompt on all lines after the first. When subclassing the control you get lots of behaviour which won't work exactly as you want it.

Resources