Autocomplete already defined variables in TextMate - textmate

Taking a tutorial on basic programming. I'm using TextMate as the text editor and can't seem to get it to pull in previously defined variables when using them later in the file.
For example, if I write:
var str = "Hello" + "World";
and then write:
alert(st
I noticed in the tutorial, the teachers editor completes it with str. I've been looking all over to see if TextMate supports this functionality, but can't seem to find it. Is this possible or do I need another editor?
This answer seems to imply that it should complete if using terms used in the same file:
Autocomplete Class methods in textmate?
But it doesn't happen that way when I'm writing. Thanks.

You can use the escape key to autocomplete.

Related

how to space multiple lines in github issues

I am copying a bunch of log output to a github issue and I want to indent it so that it is distinguishable as code/output from the rest of the issue.
How do I do this?
I tried:
CTRL+Tab
CTRL+[
CTRL+]
CTRL+Spacebar
but none seem to work? I really don't want to do every single line individually..
Wrap your code inside ```.
You can also specify language name after if your log file is analogus to any programming language's syntax.
e.g.
```yaml
You can refer Gihub Flavored Markdown for more info.

A new language, how to auto-complete in windows vim?

I'm using Gvim in windows.
Normally, when we type some character then press Ctrl-n, vim will show some tag, but those tags just includes words which have been pre-typed in the current file.
Now, I need it working in a new language, and show the tag which has been defined in other files.
So, I create a new \\.ctags for this new language, and generate tags file by exuberant-ctags.
I can choose a function in current file, then press Ctrl-] to jump to the function definition, but this function was define in the other files. It is working very well.
I don't know how to make it show the tags which are generated by ctags when I type some character.
Please help me. Thanks very much.
My English is poor, I hope you can understand what I said.
CTRL-N is just the default completion (which completes from a variety of sources, including the open buffers and also the tags database). There are many more specialized completions (all starting with CTRL-X), among them tags completion, triggered via CTRL-X CTRL-], see :help i_CTRL-X_CTRL-]. If you've correctly configured the 'tags' option (so your tags database is found) and tags jumps do work, just start using that.
Some languages / filetypes also define a language-specific completion (for language keywords etc.), usually via the 'omnifunc' option and triggered by CTRL-X CTRL-O. You could write such yourself, too.

Prevent sublime text from extracting keywords in comments for completion

How can I prevent sublime text from extracting keywords in comments?
e.g. I have the following javascript source file
// some keyword
I do not want to have either some or keyword to be in the completion list.
Thought it would be a common question but couldn't find anything on it.
If you use Sublime Code Intel - https://github.com/SublimeCodeIntel/SublimeCodeIntel - you can get read suggestions for the correct methods and variables rather that just words that are used in your code.
If you are on ST3 it's a little hard to get up and running, but it's totally doable.
I found these instructions to work https://johnblackbourn.com/sublimecodeintel-st3

How can you get vim to add a header comment to new files?

I write a lot of Rails apps these days and would like to have vim add header comments to all the code I work on..
I tend to store my projects in
~/Development/Repos/Personal
And
~/Development/Repos/Work
Can I get vim to use different copyrights etc based on where abouts the file is being created?
You can just save a header template as a plain text file and read it into a new file with :read. As for checking the path, just write a Ruby script to produce the desired text and invoke it with :read!. Creating a true vim plugin is also an option. However, why waste time learning a new language and API when you already know how to deal with text and paths in Ruby? Although, a bash script would create even less friction if you are comfortable with it.
I suggest you to use one of the many snippet plugins, like XPTemplate or snipMate, to create a 'header' snippet and then use it. The force of these plugins is that you just have to type a word and then press tab to get the expanded snippet.
Here's a snippet from my vimrc which puts in boilerplate when I create a file named test_something.rb. You can probably use a similar autocmd to conditionally add the copyright you desire. You may have to check for the expanded path in the function, but it seems doable with some vimscripting.
" Autocommands
autocmd BufNewFile *test*.rb call MakeRubyUnitTester()
"
" Functions
" Fill in the boilerplate for Ruby Unit Tests
function! MakeRubyUnitTester()
exec "normal irequire 'test/unit'
class TC_Simple < Test::Unit::TestCase"
endfunction

few vim autoinserts for ruby needed

I want to try the following things in vim insert mode:
to have closing bracket/parenthesis inserted (after the cursor) every time I type the opening one
to have #{} inserted whenever I type # inside "" (optionally, inside %() too)
I know it is possible, but my competence in this part of vim does not even reach the self-starter level.
This script will do the first one (auto inserting the closing bracket and placing the cursor between the brackets.)
lh-brackets helps define brackets related mappings. It also provides a few functions aimed at defining context-sensitive mappings and abbreviations (see Map4TheseContext).
If in ruby %() is associated to a syntax highlighting, Map4TheseContext will also solve your last request. If not, you'll have to play with searchpair() to detect the current context. Let me know if you have troubles to come up with a working solution.

Resources