Comments (3)
Undo is really only for changes affecting textual content of your document. As bookmarking only affect the margin, it isn't eligible to be part of undo.
from notepad-plus-plus.
@dogslife What do you mean by "search DD menu"? Also which of the two you mean by "previously book marked lines"=$? Because if you want $ bookmarked back: I have two ideas: if you need to bookmark certain lines you can precisely describe with a regex, and it sounds like comments could be and console.log too (I don't know js, I'm guessing), that regex won't be hard and you can ask someone for it, and I imagine it would work always in any file (it would have to be precise and well done of course). The other is: What if you after deleting the bookmarked lines, invert all bookmarks so all are selected, do ctrl+z and then invert again, that will bookmark $. But if you meant you wanted your first bookmarks, then why don't you just instead open a new document, paste all the same text, and do the operations starting with "I clear bookmarks" there? Then at the end you throw that away, and the original file hasn't been touched, still has all the bookmarks. On the other hand, I agree that the feature to add sounds incompatible with some of the mechanics of npp.
from notepad-plus-plus.
@dogslife The PythonScript plugin might be able to help to reduce the effort of you current actions.
The list of saved bookmarks are inserted into a dictionary with filename as the key to access. So, New 1
is a backup filename and C:\index.js
would be an actual filename. This allows saving of bookmarks for each buffer by it's associated filename.
Only //
javascript line comments are recognized, not multiline /*
*/
comments.
Directions:
- Run script to save bookmarks and optionally choose to add bookmarks for javascript comments...
- If new added bookmarks are OK, use Menu:
Search -> Bookmark -> Remove bookmark lines
to remove lines. - Test the document in browser and then manually save as cleaned document to pre prod folder.
- Undo document back to the origin state of bookmarks which were saved.
- Run script to restore bookmarks.
Test on a sample file first to ensure working to expectation!
# Save and restore bookmarks in Notepad++.
# After bookmarks saved, prompts to bookmark
# javascript '//' comments and console.log() lines.
# https://community.notepad-plus-plus.org/topic/23039/faq-how-to-install-and-run-a-script-in-pythonscript/1
# https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14891
from Npp import editor, notepad, LANGTYPE, MESSAGEBOXFLAGS
import re
def main():
BOOKMARK = 20
mask = 1 << BOOKMARK
title = 'PythonScript'
filename = notepad.getCurrentFilename()
message = ('Save' if not filename in savedBookmarks
else 'Restore') + ' bookmarks?'
result = notepad.messageBox(message, title, MESSAGEBOXFLAGS.YESNO)
if result == MESSAGEBOXFLAGS.RESULTNO:
if filename in savedBookmarks:
message = 'Want to remove the saved bookmarks for this buffer?'
result = notepad.messageBox(message, title,
MESSAGEBOXFLAGS.YESNO|
MESSAGEBOXFLAGS.DEFBUTTON2)
if result == MESSAGEBOXFLAGS.RESULTYES:
del savedBookmarks[filename]
return
if filename not in savedBookmarks:
savedBookmarks[filename] = []
# Save bookmarks.
for i in range(editor.getLineCount()):
if editor.markerGet(i) & mask:
savedBookmarks[filename].append(i)
# Clear bookmarks.
editor.markerDeleteAll(BOOKMARK)
# Bookmark javascript comments and console.log lines.
if notepad.getCurrentLang() == LANGTYPE.JAVASCRIPT:
message = 'Bookmark javascript comments and console.log lines?'
result = notepad.messageBox(message, title, MESSAGEBOXFLAGS.YESNO)
if result == MESSAGEBOXFLAGS.RESULTYES:
re_comments = re.compile(r'[ \t]*//')
re_consolelog = re.compile(r'\bconsole\.log\(.*?\);')
for i in range(editor.getLineCount()):
line = editor.getLine(i)
if re_comments.match(line) or re_consolelog.search(line):
editor.markerAdd(i, BOOKMARK)
else:
# Clear bookmarks.
editor.markerDeleteAll(BOOKMARK)
# Restore bookmarks.
for i in savedBookmarks[filename]:
editor.markerAdd(i, BOOKMARK)
# Remove the list of saved bookmarks.
del savedBookmarks[filename]
try:
savedBookmarks
except:
savedBookmarks = {}
main()
from notepad-plus-plus.
Related Issues (20)
- hyperlink [bug] HOT 2
- Updater windows do not pop up on top
- Potential crash when crossing Notepad++ filebuffer 2GB threshold
- BUG: In window User-Defined some Styler buttons doesn't have the right position.
- Errors while installing on Windows Server HOT 1
- Cannot register custom file extension for JSON5 formatting HOT 2
- parenthesys missing in debug info HOT 1
- [BUG] save as admin fails sometimes - filebuffer flushing fail HOT 28
- [Feature request] JSON5 style support HOT 4
- [Feature request] When automatically commenting selected block of XML, alter nested XML comment declarations HOT 2
- [BUG] Find window: Checkboxes working if clicked in blank space. HOT 22
- [BUG] WARNING - filebuffer flushing fail! HOT 1
- [Feature request] Simplify Update Process HOT 1
- Lost session of unsaved files HOT 5
- Notepad++ Theme keeps getting reset every time
- [BUG] <Current line highlighting not holding between restrating program>
- [BUG] Python, use spaces setting is overwritten (or not saved) if you close then open Notepad++ HOT 2
- Copy Link Under Caret Shortcut Key Needed HOT 2
- Improved support for importing exporting backup restoring settings and configuration and plugins and extensions HOT 1
- [Feature request] Create New Session HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notepad-plus-plus.