How to color specified text in vim? - editor

Whenever I'm typing programming keywords in vim they get specific colors.
I'd like to create my own.
How can I color text with specified color?
I tried to find the answer but haven't found it yet

to extend C/CPP syntax (and that can apply to any language, just check for the already existing names, like Constant here) :
in your ~/.vimrc
if has("autocmd")
augroup filetypedetect
au BufNewFile,BufRead *.myext setf mysyntax
augroup END
endif
and in your ~/.vim/syntax/mysyntax.vim
runtime! syntax/cpp.vim
syn keyword myConstant foo bar foobar quack
hi def link myConstant Constant
to create new keywords from scratch :
syn match myKeyWord "foobar" contained
hi kwRed term=standout ctermfg=12 guifg=Red
hi def link myKeyWord kwRed
and you can call that with filetypedetect, or directly in your .vimrc

To extend a particular filetype syntax (like e.g. Java's), use :syntax and :highlight. If you just want to color particular words in a window, you can quickly use :match, or any of the available "multiple markers" plugins like mark.vim.

Look at match
:match Identifier /\w\+/
:2match Keyword /\v(if|else|then|break)/
See also :hi to see highlight groups. Alternatively, you could write a syntax file, which is /way/ more involved

Related

How do I run a global search in DOORS?

Background
I am trying to search for specific a specific string of text that I know exists in multiple modules. However, I forget all the modules that contain this text.
Question
Does DOORS have a global search function? That is, can it search for text that exists in multiple modules as opposed to the current selected module?
Tools->Find.
Though this only looks in Object Text and Object Heading of each module.
Also, there is a "global search utility tool" available at https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014289994
Note that the last lines of the script have been garbled. The script must end like this:
if (fillModsList(GSUModList) == 0) {
insert(GSUModList, 0, "(No modules)")
}
show GSUBox, "(No modules)"

Change format of inline code evaluation in org-mode's LaTeX-export

I have a code block in an org document
#+NAME: result_whatever
#+BEGIN_SRC python :session data :results value :exports none
return(8.1 - 5)
#+END_SRC
which I evaluate inline:
Now, does this work? Let's see: call_result_whatever(). I'd be surprised ...
When exporting to LaTeX, this generates the following:
Now, does this work? Let's see: \texttt{3.1}. I'd be surprised \ldots{}
However, I don't want the results to be displayed in monospace. I want it to be formatted in "normal" upright font, without any special markup.
How can I achieve this?
You should be able to get it work using the optional header arguments which can be added to call_function().
I don't have LaTeX installed on this system so can't fully test the outputs to ensure they come out exactly as desired, I'm using the plain text output to compare instead. However you can use the following syntax as part of your call to modify the results.
Now, does this work? Let's see call_results_whatever()[:results raw].
I'd be surprised ...
Without the [:results raw] the output to Plain Text (Ascii buffer) is Let's see `3.0999999999999996'.. With the added results it becomes Let's see 3.0999999999999996.
For full details of the available results keywords as well as other optional header arguments for the inline blocks please see Evaluation Code Blocks and Results arguments.
this is 5 years later. apparently in org-mode 8.2 or so, a new variable was introduced (documenting in "Evaluating Code Blocks" in the org-mode manual, but this from etc/ORG-NEWS in the source tree):
*** New option: org-babel-inline-result-wrap
If you set this to the following
: (setq org-babel-inline-result-wrap "$%s$")
then inline code snippets will be wrapped into the formatting string.
so, to eliminate \texttt{}
(setq org-babel-inline-result-wrap "%s")
The problem of this type can be solved in two ways:
1: Easy does it:
A plain query-replace on the exported buffer.
Once you're in the LaTeX buffer,
beginning-of-buffer or M-<
query-replace or M-%
enter \texttt as the string that you want to replace
enter nothing as the replacement
continue to replace each match interactively
with y/n or just replace everything with !
2: But I wanna!
The second way is to nag the org-mode mailing list into
implementing a switch or an option for your specific case.
While it's necessary sometimes, it also produces a system
with thousands of switches, which can become unwieldy.
You can try, but I don't recommend.

What does <tt> stand for in Ruby comments?

Going over source code written in Ruby, like Rails, I often see that small code is wrapped with tt tag, like in rails/activesupport/core_ext/array/access.rb
# Equal to <tt>self[2]</tt>.
#
# %w( a b c d e).third # => "c"
def third
self[2]
end
What is the convention behind this, when and why it was decided to use this notation?
Yep, my mistake, sorry
This is a part of special RDoc system.
Non-verbatim text can be marked up:
italic: word or <em>text</em>
bold: word or <b>text</b>
typewriter: word or <tt>text</tt>
Read more about it here
Found it by myself in the Rails documentation guide.
Using a pair of +...+ for fixed-width font only works with words; that
is: anything matching \A\w+\z. For anything else use <tt>...</tt>,
notably symbols, setters, inline snippets, etc:

Guidance for how to add nicely formatted output to a custom rails generator

Like the title says - I want to add my custom output to a rails generator - much like you see identical - xxx or force - xxx
I want to add special, nicely formatted warnings for my custom generator - only I don't see any guidance for doing that, other than using puts
For example, I'd like to see:
Warining: Missing Related Data File
Where the word warning would be written in red. Very similar to what you see in a typical rails generator command...
Rails' generators are based on Thor. When you raise a Thor::Error the output will automatically be colored red. For example:
raise Error, "Warning: Missing related data file"
This will color the whole message red (and suppress the backtrace for cleaner output).
Furthermore you can use any of Thor's actions in your generator and several, e.g. say and yes?, support a second color argument, allowing you to do e.g.:
say_status "OK", "Blue is my favorite color", :blue
The available colors are shown here.
Finally, you can call set_color directly for fine-grained control of formatting, e.g.:
say set_color( "STOP ", :red ) +
set_color( "CAUTION ", :yellow ) +
set_color( "GO!", :green, true )
(If the third parameter is true the output will be bold.)
I hope that's helpful—but please use it responsibly!

How to add capybara dsl syntax highlighting to vim syntax highlighting?

I'm using Tim Pope's rails.vim plugin and for the most part it highlights nearly everything I want, except Capybara's new DSL which contains keywords like feature, scenario, background etc.
I don't want to create a new syntax file just for those two keywords, just need to add them to the existing one.
Found rails.vim file which holds syntax stuff and added the keywords.
elseif buffer.type_name('spec') syn keyword rubyRailsTestMethod describe context it its specify shared_examples_for it_should_behave_like before after subject fixtures controller_name helper_name feature scenario background
This answer gave me the hint where to look: Automate rails.vim

Resources