Using Jedit, at replace can be put a BeanShell snippet.
If you have a file with:
a
ba
abaa
And want to be like:
a1
ba2
a3ba4a5
(eg: a file with same error message in many places and you want to uniquely identify them)
Then in Jedit do:
- in search field enter: a
- change the option to use BeanShell instead of text
- enter in replace field: i=1
- press replace all
- click on main window press undo
- back, in replace field put: _0+i++
(_0 is the searched string ; + is for unification of the strings, i++ increases the value of i by 1)
- press replace all
The every appearance of the searched text is replaced with the text and the number of appearance.
Se afișează postările cu eticheta jedit. Afișați toate postările
Se afișează postările cu eticheta jedit. Afișați toate postările
luni, 1 noiembrie 2010
miercuri, 6 ianuarie 2010
jedit - locally backup with timestamp the FTP modified files
Starting from
http://community.jedit.org/?q=node/view/1209#7340 - which does only 1 file, I wanted a file for each save. I've done it using timestamp in format yyyymmddhhmmss.
(error: if system date is changed, it's possible a file to be overwritten)
//---------save-backup.bsh------------
import java.util.Calendar;
import java.text.SimpleDateFormat;
//backup path
BackupPath = "Z:\\Jedit_backups\\"; //don't forget the trailing \\
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
timestamp = sdf.format(cal.getTime());
path = buffer.getDirectory();
path = path.replaceFirst("ftp://", "");
path = path.replace('/', '\\');
path = path.replaceAll(":", ""); //this is for local files (c:\ -> c\
//todo : remove other unwanted characters ?
path = BackupPath + path;
(new File(path)).mkdirs(); //create the backup directory if it doesn't exist
path = path + buffer.getName() + '_' + timestamp;
// buffer.getLastModified(); - fails for FTP: puts 0 - all the time
buffer.save(view,path,false); //save copy
VFSManager.waitForRequests();
buffer.save(view,null,true);
Macros.message(view, "Backup done in " + BackupPath);
//--------end
- put this in a file, eg save-backup.bsh
- put the file in a subfolder (eg Files) of 'macros' folder from jedit installation
- open jedit
- Utilities > Global Options > Shortcuts
- enter, in the 'filter' field, the name of the file
- click in the 'Primary shortcut'
- press CTRL + s (the 'Save' shortcut)
- accept the override
- in 'Saving & Backup' put the 'Max number of backups' to 0 (zero - it disables other backups)
- press OK to save changes
(done in Jedit 4.3)
http://community.jedit.org/?q=node/view/1209#7340 - which does only 1 file, I wanted a file for each save. I've done it using timestamp in format yyyymmddhhmmss.
(error: if system date is changed, it's possible a file to be overwritten)
//---------save-backup.bsh------------
import java.util.Calendar;
import java.text.SimpleDateFormat;
//backup path
BackupPath = "Z:\\Jedit_backups\\"; //don't forget the trailing \\
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
timestamp = sdf.format(cal.getTime());
path = buffer.getDirectory();
path = path.replaceFirst("ftp://", "");
path = path.replace('/', '\\');
path = path.replaceAll(":", ""); //this is for local files (c:\ -> c\
//todo : remove other unwanted characters ?
path = BackupPath + path;
(new File(path)).mkdirs(); //create the backup directory if it doesn't exist
path = path + buffer.getName() + '_' + timestamp;
// buffer.getLastModified(); - fails for FTP: puts 0 - all the time
buffer.save(view,path,false); //save copy
VFSManager.waitForRequests();
buffer.save(view,null,true);
Macros.message(view, "Backup done in " + BackupPath);
//--------end
- put this in a file, eg save-backup.bsh
- put the file in a subfolder (eg Files) of 'macros' folder from jedit installation
- open jedit
- Utilities > Global Options > Shortcuts
- enter, in the 'filter' field, the name of the file
- click in the 'Primary shortcut'
- press CTRL + s (the 'Save' shortcut)
- accept the override
- in 'Saving & Backup' put the 'Max number of backups' to 0 (zero - it disables other backups)
- press OK to save changes
(done in Jedit 4.3)
Abonați-vă la:
Postări (Atom)