问题
I have a bunch of files that I have in line 7(using notepad++) this:
name: word
And I want to replace that word with the filename without the file extension .yml (the filename have just the dot from the extension, example: filename.yml), so when replaced it looks like this:
name: filename
Can anyone help me since I have no knowledge with find/replace variables on notepad++?
Examples:
name: tower
name: house
name: building
name: marcus
name: john
回答1:
You can achieve this relatively simply by AutoHotKey. It allows you sending keystrokes/mouseclicks etc. so you can quickly perform actions which are else done manually. In this case, you can automate these manual steps by sending appropriate keypresses in Notepad++. Please learn how to do the following using keyboard and then simply send those keys via AHK.
- menu
Edit>Copy to Clipboard>Current Filename to Clipboard(F10, then arrows) - Open Find/Replace dialog (Ctrl+H)
- Find what: type
filename - Replace with: send ctrl+V (paste) into this field so filename from clipboard gets pasted
- send 4 backspaces to delete file extension and dot (if your extension has 3 characters)
- press Replace All button (Alt+A)
Please see this answer for some details of AutoHotKey use with Notepad++.
来源:https://stackoverflow.com/questions/19840541/find-text-and-replace-for-filename-on-notepad