Notepad++配置技巧

來源:互聯網
上載者:User

一、全域變數

$(FULL_CURRENT_PATH) : E:\my Web\main\welcome.html$(CURRENT_DIRECTORY) : E:\my Web\main$(FILE_NAME) : welcome.html$(NAME_PART) : welcome$(EXT_PART) : html$(NPP_DIRECTORY) : the full path of notepad++'s directory$(CURRENT_WORD) : word(s) you selected in Notepad++$(CURRENT_LINE) : current line number$(CURRENT_COLUMN) : current column number

二、配置運行宏("運行"菜單的"運行"子功能表)

1. 編譯當前開啟的java源檔案

cmd /K cd /D $(CURRENT_DIRECTORY) && javac $(FILE_NAME)

2. 執行當前開啟的java源檔案對應的class檔案

cmd /K cd /D $(CURRENT_DIRECTORY) && java $(NAME_PART)

3. 編譯並運行當前開啟的java源檔案

cmd /K cd /D $(CURRENT_DIRECTORY) && javac $(FILE_NAME) && java $(NAME_PART)

三、瘋狂改造

1. 將編譯下邊的C源碼編譯成exec_head.exe,放到notepad++的安裝目錄

#include <stdio.h>#include <stdlib.h>#include <string.h>static int buf_i = 0;static int buf_size = 0;static char *buf = NULL;static void _buf_add(char c) {if (c == -1) {if (buf_i > 0) buf_i--;return;}if (buf == NULL || buf_i == buf_size) {buf_size += 1024;buf = (char *)realloc(buf, buf_size);if (buf == NULL) exit(1);}buf[buf_i++] = c;}static int _fgetc(FILE *file){char c = fgetc(file);if (c == '\n') {if (fgetc(file) != '/' || fgetc(file) != '/')return EOF;else c = fgetc(file);}if (c == '\n' || c == '#') {return EOF;}return c;}int main(int argc, char *argv[]){if (argc < 2) return 1;FILE *file = fopen(argv[1], "r");if (!file) return 1;if (fgetc(file) != '/' || fgetc(file) != '/' || fgetc(file) != '#') return 1;char c = _fgetc(file);while (c == ' ' || c == '\t') c = _fgetc(file);while (c != EOF) {if (c == ' ' || c == '\t') {do { c = _fgetc(file); } while (c == ' ' || c == '\t');if (c != ';') _buf_add(' ');} else if (c == ';') {do { c = _fgetc(file); } while (c == ' ' || c == '\t');if (c != EOF) _buf_add(';');} else {_buf_add(c);c = _fgetc(file);}}fclose(file);_buf_add('\0');char *cmd = strtok(buf, ";");while (cmd) {printf("#exec:%s\n", cmd);system(cmd);cmd = strtok(NULL, ";");}free(buf);buf = NULL;return 0;}

2. 配置運行宏,並設定快速鍵Ctrl + Shift + H

cmd /K cd /D $(CURRENT_DIRECTORY) && $(NPP_DIRECTORY)/exec_head.exe $(FILE_NAME)

3. 若當前開啟的檔案以"//#"開頭的話,程式會將"//#"至"#"之間的文本解釋成命令並執行,命令間可用";"分割,如

//#//javac Test.java; //java Test//#public class Test {public static void main(String[] args) {System.out.println("Hello");}}

4. 按下快速鍵Ctrl + Shift + H,將彈出一個CMD視窗:

#exec:javac Test.java#exec:java TestHello
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.