How do I use 'or's in AutoHotKey scripts? - conditional-statements

I have been browsing the AutoHotKey documentation, and I don't see a clear use of how to use 'or' in context specific hot keys. On my setup, Cygwin will either launch with ahk_class cygwin (when I use the context menu) or mintty (when I use the .bat or exe directly).
Currently, I duplicate the hotkeys into two separate blocks,
#IfWinActive ahk_class cygwin
...
#IfWinActive
#IfWinActive ahk_class mintty
...
#IfWinActive
Is there a way to combine them? I've tried:
#IfWinActive ahk_class cygwin ahk_class mintty
#IfWinActive ahk_class || cygwin ahk_class mintty
#IfWinActive ahk_class or cygwin ahk_class mintty
#IfWinActive ahk_class cygwin || #IfWinActive ahk_class mintty
#IfWinActive ahk_class cygwin or #IfWinActive ahk_class mintty
#IfWinActive (ahk_class cygwin or ahk_class mintty)
#IfWinActive (ahk_class cygwin || ahk_class mintty)
#IfWinActive ahk_class cygwin|mintty
#IfWinActive ahk_class cygwin||mintty
...and none of these seem to work. This post states this can be accomplished with groups, but I'm looking for a way to combine them in a single statement.

OK, last one (and tested).
#If WinActive("ahk_class ExploreWClass") || WinActive("ahk_class CabinetWClass")
Oh b.t.w. I use AutoHotKey_L, which supports #If!

Alright, I remember, after seeing an other example: Define a GroupName with multiple ahk_class entries....
GroupAdd, GroupName, ahk_class ExploreWClass
GroupAdd, GroupName, ahk_class CabinetWClass
#IfWinActive ahk_group GroupName

You could also try the following, I tested and it was working for me (AutoHotkey v1.1.14.01):
SetTitleMatchMode, REGEX
#IfWinActive (cygwin)|(mintty)
This uses the built-in OR mechanism of regular expressions. I couldn't get groups to work for some reason.

I know the question is outdated, but for those who are looking for a solution to this
#if WinActive("ahk_class cygwin") or WinActive("ahk_class mintty")
is working.

Could you try this: It is the way I do this with regular IF statements.
#IfWinActive (ahk_class cygwin or ahk_class mintty)

I found an example that uses this format:
#IfWinActive ahk_class ExploreWClass|CabinetWClass
See: Best AutoHotKey macros?

Related

How to use the terminal tabs feature in mintty/MSYS2?

According to https://github.com/mintty/mintty/issues/944 since mintty 3.5.1 there should be a tab bar where you can open multiple tabs with terminals in parallel. For that reason I performed an installation of MSYS2 which includes mintty 3.5.1, as this seems to be the way how to use the mintty. (I verified this with invoking mintty with -V.)
However, I do not find no possibility for opening and/or managing tabs in the UI.
My requirement: I would very much like to have tabs for organizing terminals in parallel.
My question: What's going on here? Did I miss something? Do I need to execute the mintty/MSYS2 with some special commad line options? How can I enable tabs?
You could use --tabbar option when staring minnty. see here for more information.
It was difficult for me to figure out how to turn this feature on. The answer is sprinkled through the comments of this issue, but not in one place. Therefore I'm posting this to save time for others. Here's how you turn the feature on:
Add --tabbar=4 or --tabbar to the windows shortcut that opens mintty:
The 4 is documented here:
no geometry handling; terminal session windows are separate [default]
sync. position/size when switching/launching/closing a session
sync. also when window is moved or resized
sync. also when window is minimized
sync. also when window is started separately
If you'd like to create new tabs with ctrl-shift-t, close tabs with ctrl-shift-w, switch to previous tabs with ctrl-shift-tab, and switch to next tabs with ctrl-tab, add -o "KeyFunctions=t:new-window-cwd;w:close" as an option to that same line.
Personally, I'd like to have ctrl-t/w open and close tabs, respectively, but the only way I've figured how to do that is to add this option: -o CtrlExchangeShift=yes. The problem is, that changes all ctrl-shift commands to become ctrl commands. That means ctrl-r no longer searches bash history.
When you run the shortcut and create some tabs, mintty will look like this:

Is there any way to switch windows in VScode via keyboard shortcut when the focus is on the terminal?

I would like to switch between windows (vscode) regardless if the focus is on the editor or on (any) terminal. I tried the key binding below in the json file without any luck. Also, dropping the "when" clause or only using terminalFocus doesn't work. It seems I can only switch windows if the focus is on the editor. Would be grateful for any suggestions.
{
"key": "ctrl+w",
"command": "workbench.action.switchWindow",
"when": "terminalFocus || editorTextFocus"
}
In my testing I see two options:
(1) It appears that any other keybinding except Ctrl+W works as expected; or
(2) add your command workbench.action.switchWindow to the Terminal > Integrated: Commands to Skip Shell list in your settings if you want to use Ctrl+W as your keybinding.

ideavim - open a file with command mode?

I'm used to quickly opening a file in vim with :e . Quick and simple, especially with tab filename completion.
However :e doesn't seem to be wired up to open files for ideavim. Typing :e has no response.
Any suggestions?
You can use :e or :edit or :action OpenFile to open IntelliJ's 'Open File' dialog and then browse to the target file but there is no auto completion available for file paths/names.
There's an open issue against IDEA VIM for this:
https://youtrack.jetbrains.com/issue/VIM-268
Double tapping shift (at least in intellij's GoLand) allows super fast searching for files in your project and opening them in a new tab. Not exactly the same as what you (and I) are looking for, but handy and fast.
:sp (alias for :split, splits editor screen horizontally) and :vsp (split vertically) also work in the way glytching described.
It's nutz that autocomplete for filename/paths isn't a feature.
I guess one sort of cool (probably unintended) feature is that you can :e, :sp, whatever just the filename of any file in your entire project. no need for path specifying (ie :sp ../../dir1/filename is unnecessary, just :sp filename works), so that's a possible workaround for the missing autocomplete.
nnoremap <leader>ff :action GotoFile<CR> works quite well for me.

How to alias 'clear' to CTRL+L keystroke

I have a habit of issuing the clear command.
When I run cygwin, the package containing clear isn't installed and I don't have the option of installing it. Ctrl+L is a good substitute; however, I still issue the clear command habitually.
I'd like to alias the clear keyword to issue the Ctrl+L keystroke. Is this possible to achieve in the .bashrc file, or something of the like?
Thanks!
clear clears the screen simply by outputting some ANSI escapes sequences. You can do the same thing with printf:
alias clear='printf "\e[H\e[2J"'

Can you turn off all caps on the menus in VS2012?

The all caps in the menus for VS2012 is highly annoying, is there a setting somewhere in the IDE or elsewhere to turn it off?
There is also another way to do this, create the following registry key and set its value:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General\SuppressUppercaseConversion
REG_DWORD value: 1
You can also run this in the Power Shell
Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\11.0\General -Name SuppressUppercaseConversion -Type DWord -Value 1
Yes; search NuGet (yes, NuGet) for VS2012 Caps.
An easy way (IMO) to achieve the registry key suggested by David would be entering it through a registry-file. This can be done by saving the code underneath to a .reg-file (e.g. VS2012_MenuCasing.reg) and double-clicking it:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General\]
"SuppressUppercaseConversion"=dword:00000001
I hope it saves somebody some time...