Increase maxTokensPerLine in Atom.IO - atom-editor

How can I increase maxTokensPerLine in my own Atom.IO environment?
I've got some long lines causing syntax to not be recognized properly, for example not highlighted correctly and brackets not taken note of etc.
But this seems to be a current source containing it. It seems to be taken as a parameter which suggests it could be configurable?
grammar-registry.coffee
I found
this.maxTokensPerLine = (_ref1 = options.maxTokensPerLine) != null ? _ref1 : Infinity;
on line 22 of /usr/share/atom/resources/app/apm/node_modules/first-mate/lib/grammar-registry.js
maxTokensPerLine also appears in
/usr/share/atom/resources/app/apm/node_modules/first-mate/lib/grammar.js
I tried adding maxTokensPerLine: 1000 in config.cson under *, core and editor, but it had no effect.
(old) maxTokensPerLine
syntax.coffee

You can use the package grammar-token-limit, which will handle changing it for you. All you need to do is specify which value you want in the package settings.
I guess if you want to do it yourself, this package would be the place to start looking.

Related

How to scroll up in Vim buffer with R (using Nvim-R)

I'm a happy user of the Nvim-R plugin, but I cannot find out how to scroll up in the buffer window that the plugin opens with R. Say for instance that I have a large output in console, but I cannot see the top of it - how do I scroll up to see this? In tmux for instance there's a copy mode that quite handily lets you do this, but how is this done in the R buffer?
An example below where I'm very curious to see what's on the line above the one begining with "is.na(a)...". How can this be achieved?
I have scoured the documentation found here, but without luck.
The answer is apparently to use Ctrl+\ Ctrl+n according to this answer on the bugreports for NVim-R.
Here's what my output looks like when I output mtcars:
When I hit Ctrl+\ Ctrl+n, I can move the cursor and I get line numbers:
To get back to interactive, I just use i, the same way I normally would.
Apparently, if you are using neovim, then you can add let R_esc_term = 0 in your ~/.vimrc file and you can then use the escape key, but if you don't use neovim, you are stuck using the two ctrl commands ¯\_(ツ)_/¯.
As pointed out by ZNK, it is about switching to normal mode in Vim's terminal. This, however, can easily fail due to cumbersome keybinding. If such is the case, remap the default keybinding to something reasonable, say, by putting this in your .vimrc:
tnoremap jk <C-\><C-n>
This works for me in Linux running Vim 8.0 in terminal (e.g. does not require Neovim). As you can see, I use 'jk' to switch from insert to normal mode. One can use Esc instead of jk, however, this makes me unable to use up arrow to retrieve command line history as been reported elsewhere.

Atom - Force Tab Width 2

I just switched from Sublime Text to Atom in order to turn completely open source.
I have trouble with something very very simple: I want Atom to use always (!) and under any circumstances tab width 2 and replace tab with spaces. This setting is so simple in gedit or Sublime Text, but no matter what I am trying: When I start a new file, tab size is 2 (good!). When I use an existing file, tab size is sometimes 4. I find that a bit annoying.
My current setting in Editor are seen in the screenshot:
There is more than one tab setting
Each package (such as python-language) has its own tab setting(s). Whether the language uses the global default or its own default is up to whoever created the package, but you can generally override it.
In your screenshot, you have set the "Tab Type" to "soft". That will take care of using spaces rather than tabs. You have left the default tab width of 2. That is your global setting.
Now, if you look under "Packages" and search for "python" you will find a package named "language-python". Click on its settings button and you will find a number of syntax-specific settings.
Python Grammar
Python Console Grammar
Python Traceback Grammar
Regular Expressions (Python) Grammar
Each of those grammars has its own Tab Length setting. You can set them explicitly to 2 here to override the package's default. (You probably mostly care about the first one, Python Grammar.)
Python is different
In the case of Python, the package is explicitly configured to default to 4 spaces, probably because Python is very opinionated about whitespace, and PEP 8 recommends 4-space indents. You can see the default package setting here in the package's source:
https://github.com/atom/language-python/blob/master/settings/language-python.cson
'autoIndentOnPaste': false
'softTabs': true
'tabLength': 4
This overrides the global default. That's why Python Grammar does not honor the global tab width, the way that most packages do.
Sometimes there are package overrides
Additionally, certain packages will override your settings for syntax reasons. For example, language-make will override and use real tabs instead of spaces, because that is required by make.
In the case of Python, there is an override to use spaces. The language-python settings page offers a spot for you to change the indentation level, but it does not offer a way to switch to using tab characters. (That's probably justifiable, as tab characters and mixed indentation in Python are a very common cause of difficult-to-debug syntax errors.)
You might need to reload
Lastly, sometimes settings don't take effect completely until you reload the Atom window. You can use the Window: Reload command to do so. Or using the keyboard:
Mac: CtrlOptCmdL
Windows/Linux: CtrlAltR
This is what worked for me.
Disable all non-default packages
Open ~/.atom/config.cson, and append this (same level than the "*" element)
:
".python.source":
editor:
autoIndent: true
tabLength: 2
Re-enable all packages.
I got this help from someone else. Not my own discovery. However, for confidentiality, I cannot cite the source.
Based on soham's answer, I found that setting all tabLength: fields in ~/.atom/config.cson (assuming osx) to your desired length solved the problem.

open graph image url problems with converted special chars XKB Symbols

I try to use the like-Button and therefor the open graph.
My problem is, that "&" and "$" chars are always replaced by & and %24
Of course, thats the normal case, but I need a clean $ and no entity there, becuase otherwise the link is not working for this image.
I could see, that facebook´s raw output produces \u0024 and so on (seems to be XKBSymbols). But if I try to put this symbols in the link in my typo3 meta-tag, it doesnt work either.
I already tried:
#page.headerData.12345.htmlSpecialChars = 0
#page.headerData.12345.htmlSpecialChars.preserveEntities = 1
#page.headerData.12345.rawUrlEncode = 0
to solve this problem, but none of those work.
Please give me a useful hint.
Thanks
try to write to your php code trough htmlspecialchar php function and add it to header with
$GLOBALS['TSFE']->additionalHeaderData['somekey'] = '...'

$ sign after each line in files(UNIX OS)

I am new to vim editor and based on general reading from different forums, I was trying to customize vim by updating the .vimrc file to look something like this:
syntax on
set incsearch
set ignorecase
set smartcase
set wildmode = list
that gives me a whole set of functionality I need. However, after having saved this content to .vimrc, suddenly all my files started to show $ as the ending character after each line.
i.e. Now even the .vimrc file looks like:
syntax on$
set incsearch$
set ignorecase$
set smartcase$
set wildmode = list$
and unfortunately I am not able to delete them in the editor. Are there any comments on how to get rid of these '$' signs? Has anyone else encountered this problem before?
Thanks in advance!
The line set wildmode = list is wrong, it should be set wildmode=list no spaces.
The line as it is queries the wildmode option and sets the boolean list option
It’s because you said set list.
Go check for init.vim file.
For me that file was at /home/user/.config/nvim/init.vim
And it was turn on "See invisible characters":
set list listchars=tab:>\ ,trial:+,eol:&
Delete or comment the line.

Why do <C-PageUp> and <C-PageDown> not work in vim?

I have Vim 7.2 installed on Windows. In GVim, the <C-PageUp> and <C-PageDown> work for navigation between tabs by default. However, it doesn't work for Vim.
I have even added the below lines in _vimrc, but it still does not work.
map <C-PageUp> :tabp<CR>
map <C-PageDown> :tabn<CR>
But, map and works.
map <C-left> :tabp<CR>
map <C-right> :tabn<CR>
Does anybody have a clue why?
The problem you describe is generally caused by vim's terminal settings not knowing the correct character sequence for a given key (on a console, all keystrokes are turned into a sequence of characters). It can also be caused by your console not sending a distinct character sequence for the key you're trying to press.
If it's the former problem, doing something like this can work around it:
:map <CTRL-V><CTRL-PAGEUP> :tabp<CR>
Where <CTRL-V> and <CTRL-PAGEUP> are literally those keys, not "less than, C, T, R, ... etc.".
If it's the latter problem then you need to either adjust the settings of your terminal program or get a different terminal program. (I'm not sure which of these options actually exist on Windows.)
This may seem obvious to many, but konsole users should be aware that some versions bind ctrl-pageup / ctrl-pagedown as secondary bindings to it's own tabbed window feature, (which may not be obvious if you don't use that feature).
Simply clearing them from the 'Configure Shortcuts' menu got them working in vim correctly for me. I guess other terminals may have similar features enabeld by default.
I'm adding this answer, taking details from vi & Vim, to integrate those that are already been given/accepted with some more details that sound very important to me.
The alredy proposed answers
It is true what the other answer says:
map <C-PageUp> :echo "hello"<CR> won't work because Vim doesn't know what escape sequence corresponds to the keycode <C-PageUp>;
one solution is to type the escape sequence explicitly: map ^[[5^ :echo "hello"<CR>, where the escape sequence ^[[5^ (which is in general different from terminal to terminal) can be obtained by Ctrl+VCtrl+PageUp.
One additional important detail
On the other hand the best solution for me is the following
set <F13>=^[[5^
map <F13> :echo "hello"<CR>
which makes use of one of additional function key codes (you can use up to <F37>). Likewise, you could have a bunch of set keycode=escapesequence all together in a single place in your .vimrc (or in another dedicated file that you source from your .vimrc, why not?).

Resources