Prefered keystroke for ending NSTextView edit - macos

Is there prefered keystroke for ending edit of an NSTextVIew? Obvious candidates are ESCape and Return with modifier key. I'd like this to be fairly intuitive and easy to type. Of course for people raised on Vim, Escape is the obvious choice.
Since I mentioned Vim, I thought I'd add my emacsish version:
For emacs I guess it might be C-x C-S. I would find this more convenient typing than ESC. But what would be the cocoa way?

Command+return is quite common for confirming multi-line input (this is used for example in Apple's iWork when editing a text frame).
In standard Cocoa text views, Esc triggers auto-completion suggestions (when applicable).

tab is the most popular to switch between different textfields and textviews and is considered as end of editing.
Also you can use any combination as per your likings, e.g. cmd+enter etc to move out of the textView.
But no to esc, it sends as something you are cancelling. However this is used in CUI as vim, but surely not in GUI for OSX and even for Windows.

Related

Sublime 4/Vintage: repeat key on key down only in edit mode

On my mac, I need to be able to access special characters such as accents for editing purposes and for now I access this by holding a key down and then get the suggestions shortcut.
However, I would like to use the Vim mode in Sublime as well so moving around with h, j, k, l is quite tedious if I can't hold the key down to move faster.
Is there any way to only repeat a key when pressing it down in edit mode, or to have this behaviour only for h, j, k, l?
Thanks
Probably unsurprisingly, the press-and-hold-for-special-characters behavior is a macOS feature. It doesn't seem possible to change the behavior on the fly. You can adjust it per app like this:
defaults write com.sublimetext.4 ApplePressAndHoldEnabled -bool false
So the question becomes: how can you enter special characters in insert mode? In vanilla vim, you could use inoremap to replace, say, Option+l with "ł". However, NeoVintageous (which I hope you're using, not the deprecated Vintage mode) does not support remaps in insert mode. It claims to support digraphs, which would be another way of achieving this. However, the keyboard command to insert a digraph is Ctrl+k, which conflicts with one of the default Sublime Text key bindings on macOS. (The one to kill from the cursor to EOL, which is copied from Emacs and available in standard macOS text fields.) It's presumably possible to work around this, but I felt like Ctrl+k+l+/ was kind of wordy anyway.
Fortunately, there IS a fast, simple solution: a Sublime key remap. Open your user key bindings (Sublime Text > Preferences > Key Bindings) and add this one:
{ "keys": ["option+l"], "command": "insert", "args": {"characters": "ł"} }
Now Option+l will add the l-slash character to your document. If you need the special character this is replacing (the not sign "¬"), you can of course choose another binding.
I presume this is the one you want, since it's the only special character available for me when I press-and-hold any of the hjkl keys. But this approach will work equally well for any other characters you might want to insert.

Using Alt Key in FakeVim mode of Qt Creator?

It's really handy when you work with VIM text editor to use Alt key to execute normal mode commands in insert mode, for example when you are in insert mode you can press Alt + j to go one line down. But in FakeVim mode of Qt creator this couldn't be done. Any suggestion is welcome.
Pressing Esc each time you want to go to normal mode really sucks.
(not a fix to your problem, just discussing it in a properly formatted text)
I never hit <ESC> as well, and this is a deal breaker for me. Note that it's not a vim feature, though : this behavior occurs because using Alt with an other key in terminals generates an escape sequence. So there's nothing wrong with FakeVim regarding Alt implementation, the problem is related to the IDE being a QT window. You can't use Alt sequence in GTK's Gvim as well, for the same reason, last time I checked.
A possible easy fix on the QCreator part : provide an option to not pass Alt combinations, like the one existing for Ctrl. That is, if QT allows that. We could then at the very least define vim bindings using Alt key to simulate the terminal behavior.
In the list of others exotic combinations from terminals that quickly lead to form habits in vim, I also use C-j in place of <return>, and C-h instead of <backspace>. Those would really be nice to have too :)

How to enable OS X cmd+ctrl+space character menu in Sublime Text 2?

In most OS X apps, even the Terminal which otherwise seems to lack features, cmd+ctrl+space brings up a character menu, where you can type in the name and look for special characters (e.g. greek alphabet). In Sublime Text 2 this does not come up; I just get the bell sound. I tried the trick described Unmap ctrl+space in Sublime Text 3 of mapping the key to the empty command, but that did nothing. Anyone have an idea of how to enable the menu?
The default shortcut for this in ST2, of course, is alt+super+t, but I assume you are wanting to remap this, right?
If so, I looked pretty hard on this one, unfortunately, I couldn't find much to help. It is not a default command, and even if you look inside Packages/Default/Main.sublime-menu, right where the "Special Characters..." line should appear, it is conspicuously absent. Logging all commands in the console using sublime.log_commands(True) shows nothing when I open the special characters window this way.

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

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).

Is there a way to change the keyboard layout in Vim on Windows?

I am working on several documents where I have to type [ ] { and the like (which is much easier with with an american keyboard layout (and to which I am used much more)) but where I also have to type Umlauts such as ä, ö and ü.
Usually, I go be setting up the (what I believe to be a standard) Windows Shortcut Alt+Shift to switch between these layouts.
This is unpractical, because at times I am not sure if I am already in the german layout when I need the german layout (and vice versa).
So, is there a better way to change the keyboard layout in Vim on *OS-level"?
I guess it could be solved with changed :map and :imap but I'd rather not use these for such porposes unless really forced to.
I don't think there is such an option - even though vim can even make pancake for you!
It'd be highly unlikely for any program to allow changing the keyboard layout of regular keys since basically any OS already supports it.
I am not sure if I am already in the german layout when I need the german layout
Do you have the language bar enabled? It should have an icon that represents your current settings.
Microsoft Knowledgebase article: HOW TO: Use the Language Bar in Windows XP
If the only thing that you need is to add umlauts easily, Vim has built-in support for adding these characters:
Method 1. In insert mode type: CTRL-K a: to give ä.
Method 2. If you use :set digraph you can enter a<BS>: to give the same result.
These methods will work with any character that needs umlauts, just use CTRL+K o: or CTRL+K u: respectively.
Source: http://vim.wikia.com/wiki/Entering_special_characters
Maybe you could be interested in some Dvorak layouts (mine is bépo, maybe it could suit you?)

Resources