Created
November 12, 2009 09:18
-
-
Save kurumigi/232753 to your computer and use it in GitHub Desktop.
[Sakura Editor Macro(JScript)]改行コードをファイルの改行コードに合わせて貼り付ける
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pasteWithReplaceLineCode(); | |
// 改行コードをファイルの改行コードに合わせて貼り付ける | |
function pasteWithReplaceLineCode() { | |
// 現在開いているファイルの改行コード | |
var lineCode = ['\\r\\n', '\\r', '\\n'][Editor.GetLineCode()]; | |
// 現在位置を移動履歴に登録 | |
Editor.MoveHistSet(); | |
// クリップボードの内容を貼り付け | |
Editor.Paste(); | |
// 貼り付け後のカーソル位置から選択を開始 | |
Editor.BeginSelect(); | |
// 移動履歴を1つ前へ = 貼り付けられた部分を選択 | |
Editor.MoveHistPrev(); | |
// 選択開始行と選択終了行が異なる = 複数行選択されている = 改行コードを含む | |
if (Editor.GetSelectLineFrom != Editor.GetSelectLineTo) { | |
// 選択部分の改行コードを置き換え | |
Editor.ReplaceAll('[\\r\\n]+', lineCode, 148); | |
} | |
// 選択解除 | |
Editor.CancelMode(); | |
// 検索マーク解除 | |
Editor.SearchClearMark(); | |
// 移動履歴を1つ後ろへ = 貼り付け終了位置に移動 | |
Editor.MoveHistNext(); | |
// 再描画 | |
Editor.ReDraw(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment