How to remap Tab key to two dots/period key presses - autohotkey

I want to map two dot/period key presses to Tab key in AutoHotkey script. I tried to map similarly as its shown for remapping semicolon key - on AutoHotkey forums, but it doesn't work. I tried following:
1. `..`::Tab
2. ..::Tab
AutoHotkey gives an error
.
I tried searching on AutoHotkey Remap docs, but couldn't figure it out. The period key is the one with the greater than mark and not the number keypad period key. See this: Dot/period key
Addition info/context in response to reply by user 0x464e:
Basically, I am trying to expand Emmet style abbreviations in devtools style sub-panel since the chrome devtools team wont implement it.
I am not a fast typist, so it's a pain to type complete property names. For example, if I want to type margin-top, (see the image), Chrome autocomplete brings up margin, margin-block margin-block-end etc.
Now, for margin-top, you need to at least type margin-t to get the autocomplete to show that property.
This is the case for many very common CSS properties like margins, paddings, etc., so autocomplete isn't great.
On the other hand, if I just type mt and have Autohotkey expand to margin-top, it's much much faster, saves me much time and keeps me sane.
Basically, I have setup some hotstring in .ahk script and they work too.
However, if I press mt followed by a Tab key press, Chrome's autocomplete takes over and hotstring fails, (try once to see the problem). Instead, currently I press spacebar, or . (period) to trigger the hotstring. It works, but the problem is it leaves a space or a dot with the expanded text. [see this].
So, that's the actual reason I wanted a double period key trigger to replace Tab.
It would be great if the hotstring trigger would work with a double period key, but doesn't leave the trigger character itself and then have send Tab so as to jump to the value input of the just expanded property.

You're not really looking for a traditional remap, which is why you didn't find it from the documentation.
Remapping is just simply remapping one key to another, but you're not trying to do that. You're trying to make some action do another action.
Anyway, what you're asking is doable, but there's loads of different ways it can be achieved with difficulties varying from simple to extremely advanced & complicated.
You'll need to specify things more clearly before this can be answered properly.
Biggest questions that pop into my head right away are at least:
Should this work everywhere, or just in text input fields?
How should the original functionality of . be preserved, if at all.
(What should happen after the initial . keypress?)
Should there be some timeout between the keypresses?
Etc, this is just what I could think of right away, but surely there's more.
Anyway, for now I can give a simple implementation with a hotstring:
:*?:..::{Tab}
So this is a hotstring with the * and ? options.
I'm guessing these would probably be pretty good options for this.
So what this does, is it presses backspace twice and sends a Tab if you type ...
This should be fine for text editors, but it leaves much to be desired (the points I listed above aren't considered since I can't know what you're looking for. This is just what a default simple hotstring can offer).

Looks to me like you don't actually want the additional mapping of .. to Tab, but instead just want to update your existing hotstrings to activate immediately (without waiting for an EndChar) when the hotstring is followed by ..
Normally, you might look to the Ending Characters option to create this functionality, but since you want multiple characters to trigger this, we need to look to other options.
I will be using the example of ::mt::margin-top for my sample implementation. Extend any changes I make to these to the rest of your hotstrings in the script you screenshotted.
Here are the changes I am making to this example:
Add your .. to the end of each of your hotstrings triggers. For example ::mt::margin-top becomes ::mt..::margin-top. However, at this present, this still requires some sort of ending character to be pressed in order to proc. Let's fix that in the next step
Add the Asterisk Modifier to the hotstring. From the docs:
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
Final code for ::mt::margin-top example:
:*:mt..::margin-top
And extend this * insertion and .. appendation to each of your hotstrings.
Hope this helped! Lmk if you need any more help or changes.

Related

notepad++ How to assign two macro to same key?

Using the GUI: I assigned a macro to allow me to select the current line my cursor is on. I assigned it to 'ctrl+a', and reassigned 'select all' to 'ctrl+alt+a'. I now want, when I press 'ctrl+a' a second time, to have it highlight the remainder of the paragraph. Currently these commands are available via the following key-press:
Instruction:
1. Home->shift+end --highlights one line
2. Home->shift+end->shift+end -- highlights connected lines
So 1. is assigned to 'ctrl+a', but I'm stuck at this point. How do I assign ctrl+a when hit a second time to highlight the connected lines/paragraph? Details/specifics in layman's terms would be appreciated. Again, I've only been using the gui options, I'm not familiar with the more codey options. Note that it doesn't allow me to use
ctrl+a->shift+end.
I'm not overly familiar with macro and hotkey binding, so I'm unaware if this is a limitation or if there's a workaround, other than writing a program to fix it.
Not a coder, but from what I know of Lua I cameup with:
is_press=false
if btn(ctrl+a) and !is_press then btn(Home->shift+end) is_press=true end
if btn(ctrl+a) and is_press then btn(Home->shift+end->shift+end) is_press=false end
I could assign 2. to ctrl+shift+a, as a separate macro if all else fails.
Short answer, I don't think this is possible with a singe shortcut/macro.
Behind the scenes, Scintilla is doing the selecting. Once you've done the selection, going back to "home" the second time will reset the word wrap extension.

prevent auto-complete expansion in emacs except for explicit binding

I want auto-complete menu to show automatically while typing but never expand except if explicitly requested (return or M-tab or such). I type very fast and I only want to potentially expand if I don't know what I want or there's a very long completion. I cannot seem to be able to prevent expansion when a single option is available in the menu and this causes big problems when there are already characters on the line right of the cursor.
Auto-complete menu shows fine. With each character the options get more narrow. Problem shows when a single option is left - the menu disappears and the overlay expansion shows (obscuring existing characters to the right of the cursor). When I type one more character the expansion takes effect but it is broken up with the remaining characters of the expansion as a suffix to the existing line. If the one more character I typed was NOT the one in the suggested expansion things still break but without the rest of the suggestion.
This is very inconvenient as I usually type very fast and trigger broken completions. I would like to have the menu always show automatically but expansions NEVER take effect except explicitly (I slow down my typing when I'm unsure what I want to type.
I tried all the options I found in the documentation but I just cannot prevent expansions from taking effect. I want to completely disable expansions (except for explicit expansion).

How can i get libreoffice writer to automatically add a closed bracket when I open a bracket?

I am currently writing my bachelor's thesis in Libreoffice Writer. To make the working process easier I wondered if there is a way to get writer to automatically add an closed bracket when I type an open one. This would be useful, because I have to quote many times and I do this by writing the quote in "..." followed by the last name of the Author e.g. (STEPHEN 2005: 44).
To keep my writing flow going on I would find it easier if I don't have to hop with my fingers so many times to simply write the source of my quote.
So, is there a way to make libreoffice add the second bracket in the moment I enter the first one and then move the cursor back into the brackets so I can continue writing?
Regards, Mario
You can set up AutoCorrect Options in the Tools menu to add in parenthesis. As a test I set up ppp to change to (). However the cursor does not end up inside.
To do this in a single key press, you would need to set up a custom shortcut key (Tools -> Customize, Keyboard tab) to call a macro. The macro would be pretty simple and could be created by recording it. This would allow you to move the cursor to end up inside, as you requested.
Instead of maintaining the references manually, for scholarly writing I recommend you use a tool such as Zotero. It has a plugin for LibreOffice. In my experience, maintaining the references manually will eventually lead to mistakes. Zotero reference stylesheets allow you to use a consistent citation style, something your professors will appreciate.

Emacs incremental search - auto remove from the search string the characters that could not be found

It's not that convenient when you do a typo during an incremental search and the search string receives the wrongly typed character. Is there a way to prevent this. As if control-g was pressed automatically on error.
For example we have the following text:
keywords
keys
Default emacs behavior:
We start incremental search and search for "keyz"
The "keyz" is displayed in the search echo area and the "key" part in "keywords" is higlighted
We press s
"keys" won't be found, the cursor stays on the "keywords" line, search echo area displays "keyzs", which is not convenient
Needed behavior:
We start incremental search and search for "keyz"
The "key" is displayed in the search echo area and the "key" part in "keywords" is higlighted
We press s
"keys" is found and highlited
You could try something like
(defadvice isearch-printing-char (before drop-mismatches-on-next-char activate)
(while (or (not isearch-success) isearch-error)
(isearch-pop-state)))
Emacs keeps the incorrect part, because it happens very often that you search for a string and it is not found, but not because it's incorrect, only the search string is found before the cursor. In this case it is very convenient that you can press C-s and the search starts from the beginning of the file.
It is very useful behavior and it happens to me more often than mistyping the search string. If there is indeed an error in the search string then you can simply press C-g to go back to last good search string.
I think the problem is that you're not thinking about searching in a way that's congruent with the way isearch has been designed to work, and so your question doesn't really make sense within the context of isearch as it currently exists.
Isearch does already give you exactly the feature what you want, but you have to tell it that you want it to happen by typing that C-g you seem so vehemently opposed to typing. If you don't tell isearch what you want to do, and when you want it to do it, how is it supposed to know what to do?
As #Tom tried to explain, the default way isearch starts from the current position in the buffer, and can restart at the beginning of the buffer if you've typed some failed characters and then press C-s, is a very valuable feature. I'm sure many people rely on this behaviour. Your method of using a macro to always start an isearch at the beginning of the buffer would confound and confuse many of us, though of course it's not a bad thing for someone such as yourself who is accustomed to it. It does mean though that the rest of us are quite confused by your dislike for having to press C-g to delete the non-matching text.
Think also for a moment about what a second C-s does if you press it immediately after starting isearch (any time but the first time in a session) (i.e. before you type any other character). Note in particular what happens if your previous search string would only partly match something in the current buffer, and then you press C-g (and also note how the failed search string is presented, regardless of whether it would partly match something in the current buffer or not).
Think also about how your feature might adversely affect the use of multi-isearch-next-buffer-function.
Claiming that other editors can do what you want isearch to do in emacs doesn't really help your case much.
I think what you really want is some slightly different type of search function which only allows you to search for text that it is possible to find in the current buffer, instead of isearch's ability to search for anything whether that text happens to exist in the current buffer or not.
Perhaps isearch-mode could be adapted to do what you want it to do, but one way or another I think you'll have to write some elisp code. Perhaps you could implement your new search mode as an option within isearch-mode that can be toggled on and off in the same way case sensitivity can be toggled on and off; and that can be set by default, again in the same way that case sensitivity can be turned on or off by default.
If you make a typo during incremental search all you need to do it press backspace to correct the typo.
We start incremental search and search for "keyz"
The "keyz" is displayed in the search echo area and the "key" part in "keywords" is higlighted
We press backspace
We press s
"keys" is found and highlited
As with most of the other answers, I'm just pointing out another feature which helps mitigate the described problem. This one is particularly useful if you've continued to type several would-have-been-good characters after the bad one.
M-e is the binding for editing the isearch string, and in the case where there are no matches for the current string, it rather helpfully places point at the first non-matching character.
So if you have made a small typo, you can quickly type M-e, fix the mistake, and type RET to return to isearch using the corrected search string.

Improved jumps to definition

When we're using ctags in vim and want to go to particular definition of variable or function we press ctrl + ], when we want to go back we press ctrl + T.
When we want to autocomplete a name of a variable we press ctrl + N and from a little violet window we can choose the right word.
Is it possible to improve go to definition so that we won't jump in the document, but only the little window with the function or variable definition will appear?
thank you
You want a way to see the function's signature without actually jumping to its definition?
I know about two plugins supposed to provide exactly this feature:
EchoFunc,
Tag Signature Balloons
The last time I tried echofunc it didn't work for JavaScript, at least for me, but it worked well for the few PHP files I've tested it with. I didn't try the other one because it's GVim-only and I use the CLI version almost as often as the GUI version.
But you can also use TagList and/or TagBar: two very useful plugins providing great code navigation based on ctags. Both will display the signature of the tag under your cursor if you hit <Space>.