Aart den Braber
Aart den Braber

Reputation: 862

Replace a string with AutoHotkey, advanced?

I'm having this issue: I program a lot in several programming languages.

I need to enter a lot of code every day, but I recently was using NetBeans and when (in Java), you type sout{TAB}, it returns System.out.println"{this is where the cursor is, so I can begin typing in here right away}";

I think this could be done using AutoHotkey, but how?

What I would like to have is a possibility to insert certain commands, like echo{TAB} and it would replace with echo ("{this is where the cursor is, so I can begin typing in here right away}");

If possible, I'd like to be able to tell where the cursor will be and copy/paste what I would like a command to be replaced with.

Regards, Aart

Upvotes: 0

Views: 597

Answers (2)

Aart den Braber
Aart den Braber

Reputation: 862

I figured it out! :)

:*:echo`t::echo (""); {left 4}

If you want to use it in PHP, for example, to type a while really fast, use:

:*:query`t::$result = mysql_query("SELECT * FROM table");{ENTER}while ($row = mysql_fetch_array($result)) {{}{ENTER}{ENTER}{}}{left 2}

Source: Always look at the readme first... :$

Upvotes: 1

CKuck
CKuck

Reputation: 712

  1. Replace the text as usual.
  2. Send CursorLeft a number of times to the end of the block you want selected.
  3. Send a ShiftDown.
  4. Move the Cursor further to the left to the beginning of the block you want selected.
  5. Send a ShiftUp.

Upvotes: 2

Related Questions