Tuesday, March 28, 2017

cpp and golang code fold problem

Hi everyone,

my .vimrc was 
set foldmethod=syntax 
filetype plugin indent on   " Automatically detect file types.
syntax enable
 syntax on  
                 
but  it cannot fold code if file was named like *.cpp, but it can work well if file was name *.c or *.cc.  golang code failed too.

my vim was installed by source code from github,runtime director is /usr/share/vim/vim80. 

I have export VIMRUNTIMEDIR= /usr/share/vim/vim80 in /etc/profile and source it.

vim version was 8.0.439. 

how can I fix this problem?
thanks

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: RFE: enable gvim to open a buffer or tab in a new window

Christian Brabandt wrote:
> Hi L!
>
> On Di, 28 Mär 2017, L A Walsh wrote:
>
>
>> If I could tear off & merge tabs it would easily allow
>> such operations.
>>
>
> You mean like tear off a tab and make it a new application window (e.g.
> before there was only one gvim window and afterwards you have 2 windows
> as seen from the operating system)?
>
-----
Perhaps, though like w/firefox, I can send a tab or drag a tab to another
window -- and it is still only 1 application (who knows how many
threads, though)...
> That is not currently possible. However it should be possible to script
> a plugin, that calls v:progpath with the current window and restores the
> view using :mkview and :loadview. However I don't know, if something
> like this exists
>
----
I'm not sure you are understanding that I really only want there
to be 1 application controlling both windows.
In the same way as when I split a window, if I change
something in 1 split, I can see the edits in another split.

In this case, I'm just wanting a it to bring up a new
window. Sorta like in explorer, if I want I can right click
on a folder and say "open folder in new window". It's still
only 1 copy of explorer, but I can have it open multiple windows
on different folders -- if I change something in one of those
windows, I see the change reflected in other windows (usually,
it's a MS-product). ;-)

-Linda


> Best,
> Christian
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Security Risk: (was vim 'less.sh' script probs w/folds)

Christian Brabandt wrote:
> On Mo, 27 Mär 2017, L. A. Walsh wrote:
>> Why would you think it shouldn't be disabled? I.e.
>> how does it help emulate the file-pagers 'less' or 'more' while
>> providing syntax-coloring?
>
> Because less.vim does what Vim would do.
====
Here is the problem -- I am not using "less.vim"...

I type in (at the command prompt):
less.sh <filename>

I'm not directly using 'vim'... I'm using a ".sh" file included that
is supposed to allow syntax highlighting.


>
> How likely is it, that a non-vim user gets into contact with less.vim?
----
See above. No contact with less.vim was needed.

>
>> It seems that if anyone was using less.sh to display files,
>> as they would 'less' or 'more' (but w/syntax highlighting), then
>> having text being hidden would seem to be a potential security
>> risk, no?
>
> Where do you see a security risk? It is pretty obvious, that a fold is
> there, so it should be easy to disable it and then you see what is
> hidden behind a fold.
----
"What's a fold" (i.e. a vim-naive user using "less.sh"
to see syntax displayed for a file). No direct contact
with 'vim' is needed to run "less.sh".
>
> How about the attached patch?
---
I am still of the strong opinion that "less.sh" as used
from the command line should do try to achieve the *primary purpose*
what it claims to do, namely:


2. Using Vim like less or more *less*

If you use the less or more program to view a file,
you don't get syntax highlighting. Thus you would like to use Vim
instead. You can do this by using the shell script
"$VIMRUNTIME/macros/less.sh".

...

----
I.e. I wanted "less" or "more" but with syntax highlighting.

I wasn't expecting a "vim-view" of my file, but a text-view
w/syntax highlighting.

Note... it also says (under :help less):

This shell script uses the Vim script "$VIMRUNTIME/macros/less.vim".
It sets up mappings to simulate the commands that
less supports. Otherwise, you can still use the Vim commands.

----
In regards to the 2nd sentence... it is also, not
quite accurate: when I saw the folds, the
first thing I tried was 'zR' (which didn't work).



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Security Risk: (was vim 'less.sh' script probs w/folds)

Christian wrote:

> > Ken Takata wrote:
> > >Hi,
> > >
> > >2017/3/28 Tue 6:19:19 UTC+9 L A Walsh wrote:
> > >>If I have a file with folds in it (fdm=3Dmarker), and I try to
> > >>display it with the vim 'less.sh' script, there doesn't seem to be
> > >>a way to get rid of all the folds (no 'zR'). I can use the cursor
> > >>keys to move to each fold and open it, but that really defeats
> > >>the idea of using 'less' to scroll through the source by pressing
> > >>'space' (for example).
> > >>
> > >>Maybe folds should be disabled for the less.sh script?
> > >
> > >I'm not sure it should be disabled. However, you can use the following
> > >command as a workaround to open all folds:
> > >
> > > :norm! zR
> > ----
> > Thanks for the workaround, but where do I put that to
> > make it default, in the the less.vim file?
>
> You can also use zi or :set nofoldenable or something like this.
>
> > Why would you think it shouldn't be disabled? I.e.
> > how does it help emulate the file-pagers 'less' or 'more' while
> > providing syntax-coloring?
>
> Because less.vim does what Vim would do.
>
> > From a different perspective, how would a non-vim user
> > know what to do to use 'less.sh' if it is supposed to be a pager
> > like 'less' or 'more' to page through file or program text without
> > having various portions of files possibly hidden.
>
> How likely is it, that a non-vim user gets into contact with less.vim?
>
> > It seems that if anyone was using less.sh to display files,
> > as they would 'less' or 'more' (but w/syntax highlighting), then
> > having text being hidden would seem to be a potential security
> > risk, no?
>
> Where do you see a security risk? It is pretty obvious, that a fold is=20
> there, so it should be easy to disable it and then you see what is=20
> hidden behind a fold.
>
> How about the attached patch?
>
> @Bram,
> please see the attached patch. It improves less.vim in several ways:
>
> - Makes 'F' toggle folds to make it easier to disable folds and also
> displays it in the help overview

"F" already has a meaning:
" Re-read file and page forward "tail -f"
map F :e<CR>G<SID>L:sleep 1<CR>F
Your patch overwrites this.

We could use "o" for open and "c" for close, since these would normally
be commands that modify the file, but with less Vim is in read-only
mode, thus these commands won't work.

> - Display 'r' key in the help overview
> - Add <nowait> to the mappings, because when trying out less.vim
> I found quite a few of the keys where not working as expected, since
> many plugins map the same keys (or the same prefix, which make Vim
> wait until the timeout triggers)
>
> On a related note, I see that less.bat and less.sh set 'no_plugin_maps'
> However only 11 of over 200 filetype plugins actually check that
> variable. I suggest to at least add a help tag *no_plugin_maps* to
> encourage filetype plugin writers to respect that variable.

I'll do that.

--
hundred-and-one symptoms of being an internet addict:
223. You set up a web-cam as your home's security system.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: RFE: enable gvim to open a buffer or tab in a new window

Hi L!

On Di, 28 Mär 2017, L A Walsh wrote:

> This is likely only pertinent to a GUI version of vim,
> like gvim running over X.
>
>
> More than once I've wanted to be able to tear off a tab
> and have gvim open the tab in a new window and
> have the new window function like a "tab"
> (or a "split") -- except the other "view" (in case of
> a split), be in a physically separate window.
>
> Just the other day, I had two files open in tabs
> (.cc and .h: a C++ source & header). Instead of
> window switching, I wanted to change my visual
> layout for 1 pair of files to see them side-by-side
> (and when I was done, close the 2nd display leaving
> the 2nd file as a 2nd tab in the 1st window.
>
> If I could tear off & merge tabs it would easily allow
> such operations.

You mean like tear off a tab and make it a new application window (e.g.
before there was only one gvim window and afterwards you have 2 windows
as seen from the operating system)?

That is not currently possible. However it should be possible to script
a plugin, that calls v:progpath with the current window and restores the
view using :mkview and :loadview. However I don't know, if something
like this exists

Best,
Christian
--
Armut, Keuschheit und Gehorsam... unerträglich sind sie alle.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Security Risk: (was vim 'less.sh' script probs w/folds)

diff --git a/runtime/macros/less.vim b/runtime/macros/less.vim
index 72b53f269..347c2b457 100644
--- a/runtime/macros/less.vim
+++ b/runtime/macros/less.vim
@@ -70,8 +70,8 @@ au VimEnter * set nomod
set noma

" Give help
-noremap h :call <SID>Help()<CR>
-map H h
+noremap <nowait> h :call <SID>Help()<CR>
+map <nowait> H h
fun! s:Help()
echo "<Space> One page forward b One page backward"
echo "d Half a page forward u Half a page backward"
@@ -84,20 +84,21 @@ fun! s:Help()
echo "\n"
echo ":n<Enter> Next file :p<Enter> Previous file"
echo "\n"
+ echo "F Toggle Folds r Redraw"
echo "q Quit v Edit file"
let i = input("Hit Enter to continue")
endfun

" Scroll one page forward
-noremap <script> <Space> :call <SID>NextPage()<CR><SID>L
-map <C-V> <Space>
-map f <Space>
-map <C-F> <Space>
-map <PageDown> <Space>
-map <kPageDown> <Space>
-map <S-Down> <Space>
-map z <Space>
-map <Esc><Space> <Space>
+noremap <nowait><script> <Space> :call <SID>NextPage()<CR><SID>L
+map <nowait> <C-V> <Space>
+map <nowait> f <Space>
+map <nowait> <C-F> <Space>
+map <nowait> <PageDown> <Space>
+map <nowait> <kPageDown> <Space>
+map <nowait> <S-Down> <Space>
+map <nowait> z <Space>
+map <nowait> <Esc><Space> <Space>
fun! s:NextPage()
if line(".") == line("$")
if argidx() + 1 >= argc()
@@ -112,103 +113,106 @@ fun! s:NextPage()
endfun

" Re-read file and page forward "tail -f"
-map F :e<CR>G<SID>L:sleep 1<CR>F
+map <nowait> F :e<CR>G<SID>L:sleep 1<CR>F

" Scroll half a page forward
-noremap <script> d <C-D><SID>L
-map <C-D> d
+noremap <nowait><script> d <C-D><SID>L
+map <nowait> <C-D> d

" Scroll one line forward
-noremap <script> <CR> <C-E><SID>L
-map <C-N> <CR>
-map e <CR>
-map <C-E> <CR>
-map j <CR>
-map <C-J> <CR>
-map <Down> <CR>
+noremap <nowait><script> <CR> <C-E><SID>L
+map <nowait> <C-N> <CR>
+map <nowait> e <CR>
+map <nowait> <C-E> <CR>
+map <nowait> j <CR>
+map <nowait> <C-J> <CR>
+map <nowait> <Down> <CR>

" Scroll one page backward
-noremap <script> b <C-B><SID>L
-map <C-B> b
-map <PageUp> b
-map <kPageUp> b
-map <S-Up> b
-map w b
-map <Esc>v b
+noremap <nowait><script> b <C-B><SID>L
+map <nowait> <C-B> b
+map <nowait> <PageUp> b
+map <nowait> <kPageUp> b
+map <nowait> <S-Up> b
+map <nowait> w b
+map <nowait> <Esc>v b

" Scroll half a page backward
-noremap <script> u <C-U><SID>L
-noremap <script> <C-U> <C-U><SID>L
+noremap <nowait><script> u <C-U><SID>L
+noremap <nowait><script> <C-U> <C-U><SID>L

" Scroll one line backward
-noremap <script> k <C-Y><SID>L
-map y k
-map <C-Y> k
-map <C-P> k
-map <C-K> k
-map <Up> k
+noremap <nowait><script> k <C-Y><SID>L
+map <nowait> y k
+map <nowait> <C-Y> k
+map <nowait> <C-P> k
+map <nowait> <C-K> k
+map <nowait> <Up> k

" Redraw
-noremap <script> r <C-L><SID>L
-noremap <script> <C-R> <C-L><SID>L
-noremap <script> R <C-L><SID>L
+noremap <nowait><script> r <C-L><SID>L
+noremap <nowait><script> <C-R> <C-L><SID>L
+noremap <nowait><script> R <C-L><SID>L

" Start of file
-noremap <script> g gg<SID>L
-map < g
-map <Esc>< g
-map <Home> g
-map <kHome> g
+noremap <nowait><script> g gg<SID>L
+map <nowait> < g
+map <nowait> <Esc>< g
+map <nowait> <Home> g
+map <nowait> <kHome> g

" End of file
-noremap <script> G G<SID>L
-map > G
-map <Esc>> G
-map <End> G
-map <kEnd> G
+noremap <nowait><script> G G<SID>L
+map <nowait> > G
+map <nowait> <Esc>> G
+map <nowait> <End> G
+map <nowait> <kEnd> G

" Go to percentage
-noremap <script> % %<SID>L
-map p %
+noremap <nowait><script> % %<SID>L
+map <nowait> p %

" Search
-noremap <script> / H$:call <SID>Forward()<CR>/
+noremap <nowait><script> / H$:call <SID>Forward()<CR>/
if &wrap
- noremap <script> ? H0:call <SID>Backward()<CR>?
+ noremap <nowait><script> ? H0:call <SID>Backward()<CR>?
else
- noremap <script> ? Hg0:call <SID>Backward()<CR>?
+ noremap <nowait><script> ? Hg0:call <SID>Backward()<CR>?
endif

fun! s:Forward()
" Searching forward
- noremap <script> n H$nzt<SID>L
+ noremap <nowait><script> n H$nzt<SID>L
if &wrap
- noremap <script> N H0Nzt<SID>L
+ noremap <nowait><script> N H0Nzt<SID>L
else
- noremap <script> N Hg0Nzt<SID>L
+ noremap <nowait><script> N Hg0Nzt<SID>L
endif
- cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L
+ cnoremap <nowait><silent><script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L
endfun

fun! s:Backward()
" Searching backward
if &wrap
- noremap <script> n H0nzt<SID>L
+ noremap <nowait><script> n H0nzt<SID>L
else
- noremap <script> n Hg0nzt<SID>L
+ noremap <nowait><script> n Hg0nzt<SID>L
endif
- noremap <script> N H$Nzt<SID>L
- cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L
+ noremap <nowait><script> N H$Nzt<SID>L
+ cnoremap <nowait><silent><script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L
endfun

call s:Forward()
-cunmap <CR>
+cunmap <nowait> <CR>

" Quitting
-noremap q :q<CR>
+noremap <nowait> q :q<CR>
+
+" Toggle folding
+noremap <script><nowait> F zi<SID>L

" Switch to editing (switch off less mode)
-map v :silent call <SID>End()<CR>
+map <nowait><silent> v :silent call <SID>End()<CR>
fun! s:End()
set ma
if exists('s:lz')
On Mo, 27 Mär 2017, L. A. Walsh wrote:

> Ken Takata wrote:
> >Hi,
> >
> >2017/3/28 Tue 6:19:19 UTC+9 L A Walsh wrote:
> >>If I have a file with folds in it (fdm=marker), and I try to
> >>display it with the vim 'less.sh' script, there doesn't seem to be
> >>a way to get rid of all the folds (no 'zR'). I can use the cursor
> >>keys to move to each fold and open it, but that really defeats
> >>the idea of using 'less' to scroll through the source by pressing
> >>'space' (for example).
> >>
> >>Maybe folds should be disabled for the less.sh script?
> >
> >I'm not sure it should be disabled. However, you can use the following
> >command as a workaround to open all folds:
> >
> > :norm! zR
> ----
> Thanks for the workaround, but where do I put that to
> make it default, in the the less.vim file?

You can also use zi or :set nofoldenable or something like this.

> Why would you think it shouldn't be disabled? I.e.
> how does it help emulate the file-pagers 'less' or 'more' while
> providing syntax-coloring?

Because less.vim does what Vim would do.

> From a different perspective, how would a non-vim user
> know what to do to use 'less.sh' if it is supposed to be a pager
> like 'less' or 'more' to page through file or program text without
> having various portions of files possibly hidden.

How likely is it, that a non-vim user gets into contact with less.vim?

> It seems that if anyone was using less.sh to display files,
> as they would 'less' or 'more' (but w/syntax highlighting), then
> having text being hidden would seem to be a potential security
> risk, no?

Where do you see a security risk? It is pretty obvious, that a fold is
there, so it should be easy to disable it and then you see what is
hidden behind a fold.

How about the attached patch?

@Bram,
please see the attached patch. It improves less.vim in several ways:

- Makes 'F' toggle folds to make it easier to disable folds and also
displays it in the help overview
- Display 'r' key in the help overview
- Add <nowait> to the mappings, because when trying out less.vim
I found quite a few of the keys where not working as expected, since
many plugins map the same keys (or the same prefix, which make Vim
wait until the timeout triggers)

On a related note, I see that less.bat and less.sh set 'no_plugin_maps'
However only 11 of over 200 filetype plugins actually check that
variable. I suggest to at least add a help tag *no_plugin_maps* to
encourage filetype plugin writers to respect that variable.

Best,
Christian
--
Das Glück ist eine leichtfertige Person, die sich stark schminkt und
von ferne schön ist.
-- Johann Nepomuk Nestroy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

RFE: enable gvim to open a buffer or tab in a new window

This is likely only pertinent to a GUI version of vim,
like gvim running over X.


More than once I've wanted to be able to tear off a tab
and have gvim open the tab in a new window and
have the new window function like a "tab"
(or a "split") -- except the other "view" (in case of
a split), be in a physically separate window.

Just the other day, I had two files open in tabs
(.cc and .h: a C++ source & header). Instead of
window switching, I wanted to change my visual
layout for 1 pair of files to see them side-by-side
(and when I was done, close the 2nd display leaving
the 2nd file as a 2nd tab in the 1st window.

If I could tear off & merge tabs it would easily allow
such operations.

Is that something that might be doable?


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.