2007/11/08
EmEditor私のマクロその4 アンカータグ付加
Scripting Weblog
http://blogs.wankuma.com/mutaguchi/
という文字列を選択して実行すると
というアンカータグをつくってくれるマクロ。IEと連携するにはこのBookmarkletを併用するといい感じです。
URLだけ選択してもそのURLへのアンカータグを作ってくれます。
便利ー。
'URLにアンカータグを付ける Set RegEx = New RegExp RegEx.Global = True RegEx.MultiLine=True RegEx.Pattern = "(http\:\/\/[\:\w\/\.\?\&\#\~\=\-\+\@\%\,\(\)]+)" Set sel=document.selection If Not sel.IsEmpty Then sText=sel.Text If InStr(sText,vbCrLf)<>0 Then sNewLine=vbCrLf ElseIf InStr(sText,vbCr)<>0 Then sNewLine=vbCr ElseIf InStr(sText,vbLf)<>0 Then sNewLine=vbLf Else sNewLine=vbCrLf End If If InStr(sText,sNewLine)<>0 Then aLine=Split(sText,sNewLine) If Ubound(aLine)=1 Then '2行の場合、1行目をタイトル、2行目をURLとみなしてリンク化 sel.Text="" & aLine(0) & "" Else '複数行の場合、URLのみをリンク化 sel.Text=RegEx.Replace(sText,"$1") End If Else sel.Text=RegEx.Replace(sText,"$1") End If sel.Collapse End If元記事:http://blogs.wankuma.com/mutaguchi/archive/2007/11/08/106982.aspx
EmEditor私のマクロその3 .vb .cs .jsのコンパイル実行
.NETアプリをFramework付属のコンパイラを使ってコンパイルし、できあがった実行ファイルexeを実行するというものです。これがまた便利でw *.vbか*.csか*.jsファイルを開いた状態で、コメント行に記述したコンパイラに渡すオプション(VB.NETなら'/r:System.Windows.Forms.Dll /t:winexeという行の/r:System.Windows.Forms.Dll /t:winexeという部分)を選択すると、そのコンパイラオプションをつけてコンパイルします。デフォルトだと/t:exeが渡されます。
'*.cs, *.vb, *.jsをコンパイルして実行 Set regEX = New RegExp regEx.Global = True regEX.IgnoreCase = True Set Fs = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("WScript.Shell") sCompilerDir = "C:\windows\Microsoft.NET\Framework\v2.0.50727\" sDefaultArguments = "/t:exe" 'winexe sSourcePath = Document.FullName sEXEPath = Fs.BuildPath(Fs.GetParentFolderName(sSourcePath),Fs.GetBaseName(sSourcePath) & ".exe") sExt = LCase(Fs.GetExtensionName(sSourcePath)) Document.Save sSourcePath 'ソース保存 Select Case sExt Case "vb" : sCompilerPath = sCompilerDir & "vbc.exe" Case "cs" : sCompilerPath = sCompilerDir & "csc.exe" Case "js" : sCompilerPath = sCompilerDir & "jsc.exe" Case Else : sCompilerPath = "" End Select Set sel = Document.Selection If sel.IsEmpty Then sArguments = sDefaultArguments Else regEx.Pattern = "\s?(\/[^\:]+\:\S+)\s?" If regEx.Test(sel.Text) Then For Each oMatch In regEx.Execute(sel.Text) sArguments = sArguments & oMatch.SubMatches(0) & " " Next Else sArguments = "" End If End If If sCompilerPath="" Then Alert sExt & "ファイルに対応するコンパイラがありません。" Else sCommandLine = "cmd.exe /k " & sCompilerPath & " " & _ "/out:" & """" & sEXEPath & """" & " " & sArguments & " " & _ """" & sSourcePath & """" WshShell.Run sCommandLine ,,True 'コンパイル実行 If Fs.FileExists(sEXEPath) Then WshShell.Run sEXEPath,,True 'コンパイルしたファイルを実行 Else Alert "コンパイルに失敗したようです。" End If End If元記事:http://blogs.wankuma.com/mutaguchi/archive/2007/11/08/106978.aspx
EmEditor私のマクロその2 HTMLサニタイズ
HTMLサニタイズ用のマクロです。やはりサニタイズをかけたいところを選択して実行してください。
'サニタイズ Set sel=document.selection If Not sel.IsEmpty Then sText=sel.Text sText=Replace(sText,"&","&") sText=Replace(sText,"<","<") sText=Replace(sText,">",">") sText=Replace(sText,"""",""") sel.Text=sText End If
これも何気に便利で良く使っています。このエントリを投稿するのにも使いましたw
元記事:http://blogs.wankuma.com/mutaguchi/archive/2007/11/08/106969.aspxEmEditor私のマクロその1 文字数カウント
EmEditorというテキストエディタはマクロがVBS/JSで書けるのが気に入ってます。私がよく使うマクロをいくつかご紹介します。その1は文字数カウントマクロです。数えたい部分を選択して(ファイル全体を数える時はCtrl+Aして)実行してください。
Set sel = document.selection alert len(sel.text)
シンプルだけど便利。
元記事:http://blogs.wankuma.com/mutaguchi/archive/2007/11/08/106967.aspx
Copyright © 2005-2018 Daisuke Mutaguchi All rights reserved
mailto: mutaguchi at roy.hi-ho.ne.jp
プライバシーポリシー