Find text and Replace for filename on notepad++

不想你离开。 提交于 2019-12-25 02:38:13

问题


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.

  1. menu Edit > Copy to Clipboard > Current Filename to Clipboard (F10, then arrows)
  2. Open Find/Replace dialog (Ctrl+H)
  3. Find what: type filename
  4. Replace with: send ctrl+V (paste) into this field so filename from clipboard gets pasted
  5. send 4 backspaces to delete file extension and dot (if your extension has 3 characters)
  6. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!