 |
 | Moving lines UP/DOWN shortcut. |  |
 | updown lines |  |
Joined: 06 Mar 2011 |
Posts: 14 |
|
|
 |
Posted: Thu Mar 24, 2011 12:40 am |
|
 |
 |
 |
 |
that would be greate if I could write integration script for this.
I've tried example scripts there http://www.nusphere.com/kb/technicalfaq/tip_some_useful_scripts.htm.
But how can I get current position of cursor in my integration script?
|
|
 |
 | |  |
 |
 | |  |
Guru master
Joined: 24 Jul 2009 |
Posts: 737 |
|
|
 |
Posted: Fri May 06, 2011 10:25 pm |
|
 |
 |
 |
 |
Moving lines up and down in PhpED can be done with AutoHotKey (www dot autohotkey dot com)
This script will do it:
; Move line down using Alt+Down
!Down::SendInput {Home}{Home}+{Down}^X{Down}^V{Up}
; Move line up using Alt+Up
!Up::SendInput {Home}{Home}+{Down}^X{Up}^V{Up} |
This script could do with being made a bit more robust (such as ensuring you are at least in PhpED), but it works fine and the script might also be valid for other applications.
I'm fairly sure that AutoHotKey can even check if you are in a PhpED editing window. If people ask about that, then I will have a look.
Bear in mind that PhpED defines Alt+Up and Alt+Down to move between editing windows, but AutoHotKey will over-ride that. You can use ^Down and ^Up to specify control key instead of Alt key.
|
|
 |
 | |  |
Joined: 08 Oct 2007 |
Posts: 32 |
|
|
 |
Posted: Thu Aug 11, 2011 8:02 am |
|
 |
 |
 |
 |
The previous script wasn't work for me in phped, so I took 2h to learn script and wrote another wich work only in phped and preserves clipboard.
The key control are Crtl + Shit + Arrow Up, Crtl + Shit + Arrow Down.
Here it is :
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Move line down using Ctrl+Shift+Down
^+DOWN::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {HOME}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{DOWN}{CTRLDOWN}v{CTRLUP}{UP}
Sleep, 50
Clipboard = %clip%
return
}
; Move line up using Ctrl+Shift+Up
^+UP::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {HOME}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{UP}{CTRLDOWN}v{CTRLUP}{UP}
Sleep, 50
Clipboard = %clip%
return
} |
You have to :
- install autoHotKey (Thanks to plugnplay introducing me to this excellent automation software  )
- save the code in a file named phpEdLineMover.ahk
- double click on it
Hope it will be usefull to some peoples
Ps: I asked this feature in "feature request" for a looong time, maybe if you post your interrest in this post
http://forum.nusphere.com/move-a-line-up-and-down-between-others-t7351.html nusphere will implement it.
|
|
 |
 | up\down |  |
 |
 | |  |
Joined: 08 Oct 2007 |
Posts: 32 |
|
|
 |
Posted: Fri Aug 12, 2011 10:47 am |
|
 |
 |
 |
 |
I don't know how to improve script to workaround the buggy case because I need to go on the start of a line, but the home touch is a switch in phpEd (start of line / start of first word), so I dont know if I'm at start or not....
Anyway here is a new version with key redirection for others programs (ex : notepad++) and phped launching (you have to change the path if needed).
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run, "C:\Program Files\nusphere\phped\phped.exe"
; Move line down using Ctrl+Shift+Down
^+DOWN::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {HOME}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{DOWN}{CTRLDOWN}v{CTRLUP}{UP}
Sleep, 50
Clipboard = %clip%
return
}else{
Send, {CTRLDOWN}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLUP}
return
}
; Move line up using Ctrl+Shift+Up
^+UP::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {HOME}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{UP}{CTRLDOWN}v{CTRLUP}{UP}
Sleep, 50
Clipboard = %clip%
return
}else{
Send, {CTRLDOWN}{SHIFTDOWN}{UP}{SHIFTUP}{CTRLUP}
return
}
|
|
|
 |
 | |  |
Joined: 08 Oct 2007 |
Posts: 32 |
|
|
 |
Posted: Sun Jan 12, 2014 12:53 pm |
|
 |
 |
 |
 |
Another update less buggy than two before (found a "way" for where the cursor is)
It still move only one line (because I can't know if lines are over lined)
Hope one day it will be native, because it's so usefull to organise code or just move a comment.
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run, "C:\Program Files\NuSphere\PhpED\phped.exe"
; Move line down using Ctrl+Shift+Down
^+DOWN::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {DOWN}{END}{HOME}{HOME}{UP}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{DOWN}{CTRLDOWN}v{CTRLUP}{UP}{HOME}
Sleep, 50
Clipboard = %clip%
return
}else{
Send, {CTRLDOWN}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLUP}
return
}
; Move line up using Ctrl+Shift+Up
^+UP::
IfWinActive, PhpED
{
clip = %Clipboard%
Send, {UP}{END}{HOME}{HOME}{DOWN}{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{UP}{CTRLDOWN}v{CTRLUP}{UP}{HOME}
Sleep, 50
Clipboard = %clip%
return
}else{
Send, {CTRLDOWN}{SHIFTDOWN}{UP}{SHIFTUP}{CTRLUP}
return
}
|
|
|
 |
 | |  |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 1
|
|
|
|  |