few vim autoinserts for ruby needed - ruby

I want to try the following things in vim insert mode:
to have closing bracket/parenthesis inserted (after the cursor) every time I type the opening one
to have #{} inserted whenever I type # inside "" (optionally, inside %() too)
I know it is possible, but my competence in this part of vim does not even reach the self-starter level.

This script will do the first one (auto inserting the closing bracket and placing the cursor between the brackets.)

lh-brackets helps define brackets related mappings. It also provides a few functions aimed at defining context-sensitive mappings and abbreviations (see Map4TheseContext).
If in ruby %() is associated to a syntax highlighting, Map4TheseContext will also solve your last request. If not, you'll have to play with searchpair() to detect the current context. Let me know if you have troubles to come up with a working solution.

Related

Highlight specific keywords in the terminal as they appear

In iTerm2 you can create triggers that highlight a line if your regex matches. This is great for some cases but I was wondering if it was possible to highlight only a word on a specific line.
The purpose of this is to help read my server logs where specific keywords can be easily pointed out. Highlighting the entire line is a bit distracting
A Profile-based trigger can highlight as much or little of a line as you choice (via the regex).
To highlight just a "word" in a line, you can create a simple Highlight Text trigger, i.e.:
Results in:
Ref: https://iterm2.com/documentation-triggers.html
Below is where you will find Triggers
As an additional usage of the selected answer, I'd like to suggest adding a tigger for "smart quotes" with the regex [”“’‘]
This will save you some day when a coworker sends you a line of code via a chat mechanism (like Slack) and the quotes get automagically "improved". The trigger won't fire as you paste/type them, but they will happen after the line scrolls up your terminal. So, it won't prevent the mistake, but it will save you time wondering why the command failed.

SPSS: Create links/anchors in syntax

Is there a way to create links or anchors within SPSS syntax? Something like linking to a bookmark.
I am making changes and additions to a syntax file, and document these changes at the bottom of the file as comments. In these comments I would like to link to the part of the syntax that was changed. Now I just write the line number, but that changes as I add more syntax, so the reference becomes incorrect.
Bookmarks were the closest thing I found to what I want to do, but I can't turn them into a link. Moreover, I can only create a maximum of 9 bookmarks, which is not enough.
Trying to think creatively here:
instead of bookmarking all the changes, you could break up your syntax into many small syntaxes - each of which contains one of the parts where a change was made.
you can name and number the small syntaxes accordingly.
Then you create one syntax which contains a series of INSERT commands, which calls each of the small syntaxes in turn. You can add titles and remarks between the insert commands, so other users can follow the process and study the relevant small syntax that they need separately.
The Statistics Syntax Editor supports bookmarks - you can have up to 10. Generate a few in the SE and save the syntax file to see how these are represented (hint: look at the COMMENT BOOKMARK lines.

Batch with comments in OrientDB Studio

I want to run a batch of queries, mostly creating and dropping indexes. In the batch call I also have a bunch of comments but the query parser keeps failing because of the comments. How do I write a comment?
I basically want to do this:
DROP INDEX oldIndex
/*
Comments
*/
CREATE INDEX newIndex ON Class (field) NOTUNIQUE
I have tried to comment with //, -- and #.
I also tried placing everything inside a transaction with begin and end but I can't drop an index inside a transaction.
Note that I'm using the studio. I made short test in the console but I still got problem with comments and lacked the overview to see any problems with my queries.
I am guessing the problem has to do with each row is seen as its own command. I suppose a command with only a comment doesn't make sense but is there any way around it?
In the meantime, use # comment-lines, that is, lines in which the first character (or the first non-blank character) is #.
I have used this in console.sh scripts in Version 2.1.x, e.g. 2.1.9, 2.1.10, and 2.1.11.
I have tried from Studio
I have found this issue https://github.com/orientechnologies/orientdb/issues/4651 about your problem with comments.
If the problem persists, you can reopen the issue.
Hope it helps.

Xcode auto completion to replace function call name - how to drop placeholders?

Xcode's auto-completion is often getting in my way by giving me argument placeholders when I already have them. Here's an example:
I want to change that second MoveToPoint to AddLineToPoint, so I delete part of the name, and hit control + space for the Show Completions command. I get something like:
You see the annoyance. I tab complete the name, but now I have to delete the 3 arguments, the commas, and the parentheses. This kind of thing annoys me and throws off my flow when writing code.
Ideally I'd like a way to delete these placeholders with one command, or have a separate auto-complete command, so along with Show Completions (control + space), I could bind something like Show Completions without Placeholders. Does anyone know how to do that?
XCode does support this actually. They call it "Select Previous Completion". Check it out here (under Code Sense).
You essentially just hit ⌃> (hold control and press >) for XCode to choose your previous completion. It think it only works well though if the new method you're calling takes the same number of arguments as the previous one.
Hope this helps

Using macros without the escape key

I am trying to use the a macro in xcode.
I type in a then hit escape and select it.
This is annoying because I have to hit page up 5 times to get to the a.
Is there a different key combination that will just let me use the a as typed without having to select it?
Have you changed your XCode defaults? I'm using 3.1.4 and I don't have to hit page up. Here are my exact key presses:
a
escape
enter
I can also hit escape first and start typing the macro name.
Edit: Argh! Your demon has infiltrated my XCode! ;) If I auto-complete some things, they become sticky as the new starting "a" macro--I can't even backspace and type "a" to use the first "a" macro. Each file has it's own persistent memory too, so switching files changes the default. Using a method or property or any other parsed symbol seems to have priority over the macros so the default will never go back to the initial "a" macro once you auto-complete a parsed symbol.
Pretty weird bug. I must not have seen it because I don't use macros much.
The only way I found to fix this is to change the "a" macro to some other auto-complete such as "ai". That way when you type "a" "escape", typing "i" next will select the macro you want even if there's a bad sticky default.
Start with this reference http://mcdevzone.com/2009/04/09/useful-xcode-tricks/
Then edit "~/Library/Application Support/Developer/Shared/Xcode/Specifications/TextMacros.xctxtmacro/Contents/Resources/ObjectiveC.xctxtmacro" and change the "CompletionPrefix = a;" to some other prefix.
When you restart XCode, the new prefix will work in place of the old "a" macro.

Resources