Insert same code around different filenames - sublimetext2

I am making a small online database that is accessible through the form of checkboxes for download. I was wondering if there was some way to list all of the filenames available for download in Sublime Text 2 and insert the same code around each filename?
Everything is functional, it would just save me a lot of repetitive copy and pasting if there is a faster way to do this.

Use SublimeText Find & Replace. Click the Regex button (it looks like a * to the left of the search box)
In the Find box, insert: (^.*$)
In the replace box: [yourcode]$1[yourcode]
Where [yourcode] is what you want to insert into the box.
So, if you want to make them all <li> then your replace box would be:
<li>$1</li>
Remember to use escape \ characters where they are needed, in case you need to insert restricted characters.
^ - beginning of a new line.
. - wildcard
* - any number of the previous character in the sequence (in this case a wildcard, so any text)
$ - the end of a line
() - denotes a block, it's how the $1 knows what text to put in it's place.
Sublime Text Search and Replace

Use search/replace on a text editor with regular expressions.
^ and $ represent the beginning and end of a line - thus allowing you to easily surround each line with the appropriate text.

Sometimes you can copy the newline character (as in copy the end of one line to the beginning of the next line), and replace that with whatever text you need.

You could always use the regular expression search / replace feature in Notepad++.

Related

Replace text next to static text google script

I would like to replace the text in a google doc. At the moment I have place markers as follows
Invoice ##invoiceNumber##
I replace the invoice number with
body.replaceText('##invoiceNumber##',invoiceNumber);
Which is fine but I can only run the script once as obviously ##invoiceNumber## is no longer in the document. I was thinking I could replace the text after Invoice as this will stay the same, appendParagraph looks like it might to the trick but I can't figure it out. I think something like body.appendParagraph("Invoice") would select the area? Not sure how to append to this after that.
You could try something like this I think:
body.replaceText('InvoiceNumber \\w{1,9} ','InvoiceNumber ' + invoicenumber);
I don't know how big your invoice numbers are but that will except from 1 to 9 word characters preceeded by a space and followed by a space. That pattern might have to be modified depending upon your textual needs.
Word Characters [A-Za-z0-9_]
If your invoice numbers are unique enough perhaps you could just replace them.
Reference
Regular Expression Syntax
Note: the regex pattern is passed as a string rather than a regular expression

right side alt shift in sql

How does one append all lines in a SQL query with text?
In order to add something to the front of my lines of code I can use Alt+Shift down the left side and type something to change
example-1
example-12
example-123
example-1234
example-12345
to
a.example-1
a.example-12
a.example-123
a.example-1234
a.example-12345
but if I want to add something to the right side, it turns out like this
a.example-1*
a.example-1*
a.example-1*3
a.example-1*34
a.example-1*345
when i want it to look like this
a.example-1*
a.example-12*
a.example-123*
a.example-1234*
a.example-12345*
So, how do I do this? Is it possible to append all lines with something with Alt+Shift or is there another method?
*Edit example
To clarify, I need to edit the text in my SQL code, not the text within my tables and such. Ex.:
SELECT TOP 1000
[day]
,[workout_name]
,[reps]
FROM [tom].[dbo].[workout_routine]
but instead of having the commas at the beginning of [day], [workout_name], let's say I need them at the end, like:
SELECT TOP 1000
[day],
[workout_name],
[reps]
FROM [tom].[dbo].[workout_routine]
Because Alt+Shift works and aligns at any column of text, but I need to know if there is a way to be able to add something to the end of lines of differing lengths.
There is a Concat function in mysql.
Select concat(row, ' text after row') from table
If you're looking to modify a script, you can use Regex to replace $ which represents the end of line character. So if you were in Notepad++, you can do a find and replace for $. Make sure you allow Regular expression in the search mode.

Notepad++ tabs to spaces everywhere other than beginning of line

Due to a new coding style that I've been having to use I'm required to use tabs in the beginning of lines but spaces everywhere else to align things.
Is there a way to customize notepad++ to only replace tabs with spaces if it's not at the beginning of a new line?
Just as an example of what I mean I'll use this bit of 'code':
function someFunction():
while(true):
veryLongCodeStuff() // Some comment
shortCode() // Aligned comment
Which I would have to write like this (where \t = tab and a "." represents a space):
function someFunction():
\twhile(true):
\t\tveryLongCodeStuff()..// Some comment
\t\tshortCode()..........// Aligned comment
To convert existing files, I would suggest a two step approach:
replace all tabs with spaces (this can be done with Edit -> Blank operations -> TAB to Space )
replace spaces at the beginning of lines: do a regular expression find/replace like this:
Open Replace Dialog
Find What: ^([\t]?)( ){4} instead of 4 use the number of spaces you have configured as tab width
Replace With: \1\t
check regular expression
click Replace All: as each Replace All replaces only one indent level for all lines: repeat until the status bar of the find dialog tells you, that no more replacements were done (just keep Alt-A pressed for a second or two)

Double click to select words connected with break

I am using Sublime Text 2 and when I double click on word connected with underline like:
this_is_it
it will auto select whole phrase, but when is words connected with break symbol like this:
this-is-it
it will select only one of words, how can I set Sublime Text to select whole phrase?
Modify "word_separators" in user's Preferences.sublime-settings, the default is:
"word_separators": "./\\()\"'-:,.;<>~!##$%^&*|+=[]{}`~?"
Since - is minus in most programming language, it is included as default separator. You better modify syntax specific files (e.g. Plain text.sublime-settings) to suit your need.
http://compscientist.com/post/28272180856/word-separators

How to replace a specific line of HTML code with Regular Expression In Dreamweaver?

I want to replace <whatever>Some Title</whatever> with <something>Some Title</something> using the Find and Replace tool inside of Dreamweaver. How do I perform?
Not a Dreamweaver user, but this simple approach works in my editor (Emacs):
Replace:
<whatever>\(.*\)</whatever>
With:
<something>\1</something>
This is a pretty straightforward approach but it may fall short of your needs. Do some or all of your <whatever> element pairs occupy more than one line of text? Or do you have more than one <whatever> pair on a single line?
i guess what you want is to change all your <whatever> tag with an <something> tag whitout changing your text, right?
If it is so, you want to use find and replace with regular expression. Find (in source code) <whatever>(.*)</whatever> and replace it with <something>$1</something>. The $1 is used as a variable for anything fits the (.*) part DW finds for each instance.
For example, you you want to comment all instances of an
document.NAMEOFANYFORMONTHEPAGE.WHATEVERNAME.focus();
in a JavaScript file, you would use find:
document\.(.*)\.focus\(\);
and replace it with:
// document.$1.focus();
Don't forget to escape special characters and, please, try a few instances before using Replace All