I’m just learning ST3 - I’m on build 3103 - for some odd reason, whenever I call any snippet beginning with <, the snippet is activated but the beginning “<” is left along with the snippet, leaving me with code that begins with “<<”. I have no idea what might be causing that? Greatly appreciate any help or advice.
[Solved] Snippets leave beginning <
Is this a snippet you created yourself, one that comes with Sublime itself or a plugin?
You might be running afoul of thinking that the html tag completions/snippets require you to type the leading ‘<’ character to trigger, but they don’t.
For example, in a blank HTML file, just “html” will expand to a blank document, so if you type “<html” you get the replacement text for the “html” part but the “<” part you typed yourself is left behind.
Thanks! I was typing <bs3
to bring up all the bootstrap 3 snippets - and it continually leaves the initial “<” behind once I choose the snippet I would like to use. As far as I know, the only way to trigger sublime to present me with the snippets is by using the preceding < with bs3. It just seems very odd that it leaves the initial “<” behind. It also does the same with “<html
” or any other snippet “called” with a beginning “<”.
You can manually trigger auto completion with the keyboard. On Windows that is Ctrl+Space.
If you match the snippet’s tab trigger exactly, you also don’t need the auto-completion popup at all but can just press Tab after bs3
.
That’s the oddity I’m encountering. I must type in < before bs3 to bring up the selection of bs3 snippets to choose from. When I choose one, it goes into “snippet mode”. It just leaves the original <. It’s not that hard to go delete it, but it just seemed like I must be doing something wrong because Sublime is otherwise so lean. bs3 plus tab does nothing.
I’m guessing I must be doing something wrong. I just think it’s awesome that I can type in <bs3
and be presented with every possible bootstrap snippet. So I guess I shouldn’t complain about having to go back and delete the <. Again, just seemed odd.
In fact, I deleted all of my data and installed packages just to see if I had another package that was interfering - but nope.
Thanks. Yes, it’s bs3-sublime-plugin.
But I don’t believe it’s the snippet plugin, as if I type in <h
to bring up the html snippet, it also leaves the preceding < that I typed in to bring up the list.
With the Bootstrap 3 Snippet plugin, the easiest way to bring up all variants is to type in <bs3
- I can then scroll down the list, hit tab or enter and boom - snippet magic.
The trouble seems to be that I’m using < before to “call up” the list as I’m typing, and then sublime leaves the initial <. It may be that I shouldn’t be typing in < before them to bring up the lists, but some other character?
Thanks again so much for everyone’s help and advice. I’m just learning and I greatly appreciate everyone’s advice and effort. I sincerely hope I’m not just being an idiot and wasting everyone’s time.
Snippets aren’t activated by <
, just the h
after it, hence the “leaving behind” of the <
. In your case you just need to type bs3
to bring up the list.
For the relatively rare situation where the snippet trigger contains part of the resulting snippet that is not the first characters, more specific handling needs to be done.
We fixed the HTML snippet recently, and it will be part of the next dev build. We also solved a similar issue with C++ and #inc
in one of the past few dev builds.
I’ve been thinking about a more general solution, however I’m sure there will be edge cases with any such solution.
As you’re obviously a n00b like me, I’ll break it down for you.
I’m typing in Sublime Text right now - and typing in bs3 - and nothing. However, if I type in <bs3
- with HTML syntax turned on, all of my text is now green.
I was following the tutsplus tutorial on Sublime Text 2 when I ran into the issue.
This is actually insane - I started a new document with HTML syntax turned off. bs3 brings up nothing. bs3 still brings up nothing.
Now, bs, just b - brings up everything, with syntax turned on. In a new document, prescribed HTML syntax.
It’s an odd bug, no doubt. b again brings up everything.
Here’s the code, syntaxed in HTML, where bs3 does nothing:
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Bootstrap Portfolio 2016</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<!-- Modernizr -->
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<!-- Respond.js for IE 8 or less only -->
<!--[if (lt IE 9) & (!IEMobile)]>
<script src="js/vendor/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<header role="banner">
<nav role="navigation" class="navbar navbar-static-top navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
</header>
bs3
<main role="main">
<h1>Main Heading</h1>
<p>Content specific to this page goes here.</p>
</main>
<footer role="contentinfo">
<p><small>Copyright © 2016, <a href="http://www.nevermind.com" target="_blank">Never Mind</small></p>
</footer>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.12.0.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='https://www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
</script>
</body>
</html>
bs3 doesn’t even work at the end of this, or in the middle of it, wherease <b
brings up everything.
This is just normalizer with a very small bit of bootstrap code. No clue?
If you can somehow get a copy of Sublime - it’s freely available on the web from some random coder dude - I guarantee you’ll see similar results.
Also, just as an aside - my friendgirl is a model and very much into everything Hollywood - so I just went off for an HOUR that Will MF Bond had bothered to reply to me. So thank you!!! You are a Fn GOD!!! Now she knows who you are. And not bragging about the model crap - whatever - just commenting on how people who actually CONTRIBUTE to society who should be famous v. the dbags…
She meets Ralph Lauren. I get a response from Will MF Bond. Highlight of my life this year! Thank you.
FWIW, the package is named “Bootstrap 3 Snippets” on package control. (link)
Here are your solutions:
- Go to “Preferences > Settings - User” and add the following entry:
"auto_complete_selector": "text.html.basic, source - comment - string"
Then just type bs3
in some HTML file.
2. OR
Type bs3
and then hit Ctrl+Space (Windows), Alt+/ (Linux) or Ctrl+Space (OSX).
Ok, so this is a result of the fact that it is in HTML, and the auto_complete_selector
and auto_complete_triggers
settings affect where completions are shown.
By default, completions are shown in source
with the exception of comments and strings. HTML, however is text.html
, so there is a special exception that allow completions to happen after <
.
As a third alternative to what @FichteFoll said, you can type the full name of the snippet and hit the tab key.
I learn new things every day .
@FichteFoll’s settings worked like a charm!
Thank y’all VERY much! Will MF Bond!!! Awesome.