Here is the question. I have a daunting task of deleting over 1400 entries of code manually.
This is what I have. Everything before the <!-- Begin Description --> has to be deleted and everything after the <!-- End Description --> also has to be deleted. I need a script or something that can do this for me. Can anyone help?
With awk :
awk '/<!-- Begin Description -->/,/<!-- End Description -->/' file.html > new_file.html
example :
$ cat file
some code
foo
<!-- Begin Description -->
some description
to keep
bar
<!-- End Description -->
some stuff
to remove
baz
$ awk '/<!-- Begin Description -->/,/<!-- End Description -->/' file
<!-- Begin Description -->
some description
to keep
bar
<!-- End Description -->
if you have 1400 files, you can make a loop in a shell :
for file in *.html; do
awk '/<!-- Begin Description -->/,/<!-- End Description -->/' $file > ${file%.html}_new.html
done
Related
I am using rosbridge. My current ros_distro is melodic. I cannot subscribe to custom messages with an error : Unable to load the manifest for package <pkg_name>. I sourced the bash file in another terminal : . ./devel/setup.bash and used rospack find <pkg_name> but this also gives an error : package not found.
This is strange as I can publish and subscribe to the same topic in ROS.
My directory structure looks like following :
overlay_ws
build
devel
src
CMakeLists.txt
ros_tutorials
CMakeLists.txt
package.xml
msg
msg1
msg2
msg3
scripts
talker.py
Here is the package.xml:
<?xml version="1.0"?>
<package format="2">
<name>ros_tutorials</name>
<version>0.0.0</version>
<description>The demo package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe#example.com">Jane Doe</maintainer> -->
<maintainer email="vishal#todo.todo">vishal</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
I wish to copy some twig files while removing the 'src' suffix
example: someCode.html.src.twig
with the result : someCode.html.twig
using gulp rename as I must have this change implemented for several files that all have the src suffix.
I also wish to maintain the directory structure:
example:
D: test --> formsDirectory --> someFile.html.src.twig
, someotherFile.html.src.twig
--> SomeOtherDir --> onemore.html.src.twig
result:
D: someDir --> formsDirectory --> someFile.html.twig
, someotherFile.html.twig
--> SomeOtherDir --> onemore.html.twig
I know that I can use gulp rename to remove the extension and basename however I wish to only change the suffix are illustrated. Any Help would be Great! thanks
Use gulp-ext-replace
Example:
.pipe(ext_replace('twig', '.src.twig'))
I tried using snippets in Sublime Text - I created a document hello.sublime-snippet in /Users/davidfaux/Library/Application Support/Sublime Text 2/Packages/User:
<snippet>
<content><![CDATA[
alert("hello {$1}");
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.js</scope> -->
</snippet>
Then, I created a new file called hello.js on my Desktop:
document.onload = function() {
hello
}
However, when I press tab after hello, nothing happens. Why not? I tried setting "auto_complete_commit_on_tab": true in my User settings, and this attribute seems to be working for autocomplete.
Any advice on directions for debugging appreciated!
You are using a template to create this snippet. So you need to uncomment the lines that actually define the snippet.
The quick way to do this in ST2 is to select the entire line and press ctrl+shift+/ to remove the comment markings.
The lines you need to uncomment are the <tabTrigger>hello</tabTrigger> line and the <scope>source.js</scope> line. Then this snippet should work fine as long as you are putting it in a .js file.
Also, I prefer using Enter to auto-complete as Tab is also used in ST2 for navigation.
As others have mentioned, the parts of the snippet that determine its tab trigger are currently commented. XML comments look like this:
<!-- ...commented content... -->
You've left both the tabTrigger tag line and the scope tag line commented, so hello will not expand to the snippet content—the only way to activate the snippet now is via the Command Palette—nor is the snippet's scope actually restricted to Javascript files. You'll have to remove the commenting from those lines (Ctrl+/ is the default single-line comment toggle on Windows) for them to have any effect, like this:
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>hello</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
You can read more about snippets at the Unofficial Docs Snippets page.
Uncomment <tabTrigger> and it will work when you press tab after hello
I create a lot of snippets for Sublime Text 2. I always use the optional tab trigger and never use the trigger scope. I'd like to edit the 'New Snippet' template so I don't have to uncomment and delete these respective options every time.
TL;DR - Where does this default 'New Snippet' text come from so I can change it:
<snippet>
<content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
The new snippet command is defined in Packages/Default/new_templates.py. Edit it there. (I found it by opening Packages in sublime and searching for one of it's lines.
class NewSnippetCommand(sublime_plugin.WindowCommand):
def run(self):
v = self.window.new_file()
v.settings().set('default_dir',
os.path.join(sublime.packages_path(), 'User'))
v.settings().set('default_extension', 'sublime-snippet')
v.set_syntax_file('Packages/XML/XML.tmLanguage')
template = """<snippet>
<content><![CDATA[
Hello, \${1:this} is a \${2:snippet}.
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
"""
I'm just new in Sublime and I just created a new snippet saved in an HTML folder. My problem is the created snippet doesn't display the auto-complete box. I need to type the whole word in tab-trigger, then hitting tab twice. Below, you'll see it working in JavaScript syntax.
<snippet>
<content><![CDATA[ <ccbn:html-block> ${1} </ccbn:html-block> ]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>hblock</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
If you want the snippet to kick in when you're editing HTML, then I think you need to change your snippet's <scope> to text.html