agelessdummy / vimwiki

Automatically exported from code.google.com/p/vimwiki
0 stars 1 forks source link

How to escape dollar sign? #417

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Pretty self-explanatory.  I searched all over the documentation.  Math mode is 
fine and good, but sometimes I end up with two dollars signs on the same line 
and vim interprets it as math mode instead of dollar sign literals.

I've tried \$ and $$ (backslash before and doubled dollar sign); neither works.

I'm using vimwiki 2.1

Original issue reported on code.google.com by cyberdup...@gmail.com on 26 Jun 2013 at 11:56

GoogleCodeExporter commented 8 years ago

Original comment by habamax on 29 Jun 2013 at 7:25

nikinbaidar commented 4 years ago

Hi,man. I found a way to solve this issue. We can modify the source code of vimwiki for the sake of this. We can find in /path-to-vimwiki/syntax/vimwiki_default.vim:

" text: $ equation_inline $
let s:default_syntax.rxEqIn = '\$[^$`]\+\$'
let s:default_syntax.char_eqin = '\$'

and we change it to:

let s:default_syntax.rxEqIn = '✹[^✹`]\+✹'
let s:default_syntax.char_eqin = '✹'

I hope this helps.

corbolais commented 4 years ago

@nikinbaidarr didn't test your change.

Problem persists if you save source code snippets/gists in vimwiki.

Using variable names with language syntax requiring a leading '$' (as i.e. in PHP) will transform into the code into invalid chunks. Useless to copy and paste. Only the line where the cursor is will be shown/copied/expanded correctly.

Very unfortunate.

nikinbaidar commented 4 years ago

Hello! @corbolais Have you tried placing your code snippets inside code blocks? If your using default vimwiki syntax use

{{{ 

   " Snippet goes here

}}}

Or if you want language specific highlighting.

{{{php

   "  Snippet goes here

}}}
corbolais commented 4 years ago

@nikinbaidarr Thanks, {{{ is working. Syntax highlighting is not, however.

nikinbaidar commented 4 years ago

@nikinbaidarr Thanks, {{{ is working. Syntax highlighting is not, however. Check whether if you have syntax enable in your vimrc. If you do, vimwiki will use the syntax highlighting defined for you php files. But it if your using the fenced code for the first time in your file it does not work instantly after you place the code within {{{, you have to reload your file. Now this does not work for everything but it most certainly does for major programming languages, and it works for PHP as well. Here's a screenshot Screenshot from 2020-09-15 17-36-32

corbolais commented 4 years ago

@nikinbaidarr Thank you for your feedback. VIM has syntax highlighting enabled. After Reloading the file PHP syntax highlighting is not working, though.

nikinbaidar commented 4 years ago

@corbolais Try putting the following line in your vimrc.

autocmd FileType vimwiki :syntax enable
corbolais commented 4 years ago

@corbolais Try putting the following line in your vimrc.

autocmd FileType vimwiki :syntax enable

Not working.

jpheldson commented 3 years ago

@corbolais Try putting the following line in your vimrc.

autocmd FileType vimwiki :syntax enable

Not working.

Are you sure it's not working? Make sure you've included the opening php tag in your code snippet "<?php". Remember that without that opening tag PHP will treat any text as plaintext to be sent to stdout, and most syntax highlighters are aware of this:

tag_before_after

corbolais commented 3 years ago

Thanks for your feedback.

It is indeed working using:

{{{php
<?php
  foreach ( is_iterable($this) )
}}}

The important bits are {{{php and <?php. Before I used either one but not both at the same time. Might be worth hinting at in the documentation. Just in case.

Thank you.