Vdebug Expand All Variable Trees - vim

Is there a way in Vdebug to expand all the "variable trees" without manually going through each and expanding them?
A picture to explain what I mean by variable trees (the arrow is the top of a tree).

I didn't know about Vdebug, but from the help file:
4.2.2 The watch window *VdebugWatchWindow*
:
:
To open a closed tree, navigate to a line with a closed tree (right arrow) and
press <enter> (<cr>) or double-click if you have mouse-support enabled. This
will open the tree, and show all the children.
:
:
*VdebugOptions-marker_closed_tree*
g:vdebug_options["marker_closed_tree"] (default = '▸')
Sets the marker used for a variable in the watch window that does have
children, but the tree is currently closed. A "+" symbol is used if multi
byte support is not enabled.
So you could use the :global command to hit enter on every line containing a closed tree marker:
:exe 'g/'.g:vdebug_options["marker_closed_tree"]."/ normal \<cr>"

I was not able to get mMontu's answer to work for all occurrences but it did work for the first occurrence. I also changed it a tad to make it so I didn't have to hit return to actually execute it.
exe 'g/'.g:vdebug_options["marker_closed_tree"]."/normal \<cr><cr>"
It also works for "open" markers, which is what I wanted. For some reason mine are all open by default which makes for hard reading. So, conversely to OP (Kyle) wanted (all open by default) I wanted all closed by default.
exe 'g/'.g:vdebug_options["marker_open_tree"]."/normal \<cr><cr>"

Related

VIm change bracket types (without using search and replace) [duplicate]

This question already has answers here:
Quickest way to change a pair of parenthesis to brackets in vim
(6 answers)
Closed 8 years ago.
I am looking for a VIM key combo for changing something like
blahblah["hello"]
to
blahblah("hello")
My best effort so far is
0f[yi[%c%()^["0P^[
but anything better would be much appreciated.
BTW, my combo works by doing:
find the first instance of [ (you get my point),
yank the insides (which of course means to register 0 by default, and it leaves the cursor on the first "),
move the cursor back onto the first instance of [ with %,
delete the whole [...] bit and go into insert mode,
write () and <Esc> out of insert mode,
paste the contents of register 0 in between the ().
I was hoping to have a muscle-memorable key combination that I could use for things like this where you want to 'keep the contents but change the surroundings'.
My proposal, if you reduce it to the minimum (and use ca[ rather than %c% -- credit to this SO for the a motion that I had not really known about) is not too bad because it is the sort of thing you can invent again once you know it is possible:
yi[ca[()<Esc>"0P
However, it occurred to me that a search-and-replace is going to be just the right kind of solution when you need to do a few of these in a file. Here is my best effort:
select the area in visual mode (I tend to use VISUAL LINE mode as a default),
then :s/\[\(.\{-}\)\]/(\1)/g<Enter> and you're done.
That itself looks a bit mad, but it is just a simple example of so-called backreferencing so I was quite happy to have had to get that clear in my mind too.

"paste inner", similar to "yank inner" [duplicate]

This question already has answers here:
Pasting inside delimiters without using visual selection
(5 answers)
Closed 8 years ago.
Is there any known, straight-forward way to perform inner <text-object>-functons in Vim similar to yank-inner and delete-inner, only with paste? I know how to do this with Visual mode but it feels a few steps too long.
Example:
delete-inner (di<text-object>):
user.name("Carl") -> di" -> user.name("") + Carl is copied to clipboard.
Now, I occasionally find myself wanting to do something like this as well:
user.name("") -> pi" -> user.name("Carl")
I don't like taking the extra step inside Visual-mode, nor performing acharacter/string-search (/,f,t). Is there any way around this? Plugin-recommendations are also welcome if necessary.
I need this so often, I wrote a plugin to simplify (i.e. without the intermediate visual mode) and allow maximum speed: ReplaceWithRegister.
This plugin offers a two-in-one gr command that replaces text covered by a {motion} / text object, entire line(s) or the current selection with the contents of a register; the old text is deleted into the black-hole register, i.e. it's gone. It transparently handles many corner cases and allows for a quick repeat via the standard . command. Should you not like it, its page has links to alternatives.
So, your example would be g r i ".
Edit: Previous plugin versions didn't handle an empty text object well; fixed in the latest version 1.41.
"_di"P
works for me, it pastes to the left instead of right which leaves it inside the quotes
assuming you want to change the value with the one on the clipboard
Alternately you can use :map to map pi" to either the command above or the Visual method keys

In Vim, how to keep characters concealed even when cursor enters that line

I may have a unique situation here. I want gVim (gui version, in Linux) to keep concealed characters concealed no matter what, even when the cursor is on that line or that character gets selected. (It should be as close to if the characters never existed as possible.) Currently the concealed characters show themselves when the cursor enters that line, which causes text to jump around when scrolling and when selecting text.
We are using gView (read-only gVim) to view logs, so as to take advantage of its robust syntax highlighting. Problem is, these logs contain lots of escape characters and TTY color codes, that make reading difficult. (^[33mSomeText^[0m)
I'm using this line to hide them:
syntax match Ignore /\%o33\[[0-9]\{0,5}m/ conceal
Since the files are viewed by non-vim-experts, it looks glitchy and broken when the text un-conceals itself. (And also looks glitchy and broken if the color codes are present, and also looks glitchy and broken if the color codes are blacked-out to become invisible, but still show when selected and appear after copy/paste.)
This should be fine because these files are opened read-only in gview, with an extra set nomodifiable making it even more difficult to save the file. While it's possible to edit and attempt to save the logs, doing so is considered both an invalid thing to do, and a harmless thing to do, and requires enough Vim skills that if someone manages to edit a file they know what they're doing. The problem with being able to edit a line with concealed text does not apply.
If 'conceal' can't be configured to keep hidden text hidden no matter what, an acceptable alternative would be to replace the TTY color codes with whitespace when the file gets opened. But, this has to be done in read-only mode, and we can't have gview throwing up a save dialog on closing the window because the file has been modified by its .vimrc.
Note: I am in full control of the .vim script file sourced when these are read, but cannot control the existence of the TTY color codes or the code that opens the log files in gview. (i.e. I can't pass it through sed or anything like that.) The ideal solution is anything that can transparently nuke the color codes from within a .vimrc, but I'll hear any suggestions. The 'conceal' feature is just my most promising lead.
So, any ideas how to permanently get rid of these on file view without dialogs popping up on close?
:help conceal
When the "conceal" argument is given, the item is marked as concealable.
Whether or not it is actually concealed depends on the value of the
'conceallevel' option. The 'concealcursor' option is used to decide whether
concealable items in the current line are displayed unconcealed to be able to
edit the line.
:help concealcursor
Sets the modes in which text in the cursor line can also be concealed.
When the current mode is listed then concealing happens just like in
other lines.
n Normal mode
v Visual mode
i Insert mode
c Command line editing, for 'incsearch'
'v' applies to all lines in the Visual area, not only the cursor.
A useful value is "nc". This is used in help files. So long as you
are moving around text is concealed, but when starting to insert text
or selecting a Visual area the concealed text is displayed, so that
you can see what you are doing.
Keep in mind that the cursor position is not always where it's
displayed. E.g., when moving vertically it may change column.
Also, :help conceallevel
Determine how text with the "conceal" syntax attribute |:syn-conceal|
is shown:
Value Effect ~
0 Text is shown normally
1 Each block of concealed text is replaced with one
character. If the syntax item does not have a custom
replacement character defined (see |:syn-cchar|) the
character defined in 'listchars' is used (default is a
space).
It is highlighted with the "Conceal" highlight group.
2 Concealed text is completely hidden unless it has a
custom replacement character defined (see
|:syn-cchar|).
3 Concealed text is completely hidden.
Only one command is needed: set concealcursor=n
I might have a better idea—you can pass it through sed (using %!sed) or really do a bunch of other :substitute commands—whatever edits you need to get rid of the color codes.
When you’re done, make sure to set nomodified—this forces vim to think there haven’t been any changes!

What does <++> mean in gvim? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What does <++> mean in vim (latex-suite), and how do I jump there?
My default editor is vim but I shifted to gvim for the latex suite. Whenever I type $$ in quick succession it adds a <++> after the second $ symbol. What does that mean and how do i disable that?
From the Vim-Latex FAQ:
Q: What are those annoying «» characters whenever I invoke a
mapping?
Those are called placeholders and when you get used to them, they
will prove invaluable. They are essentially markers left in the text
file to tell latex-suite where the next point of interest is. This
lets you directly go to the next placeholder with a single key-press.
Consider a working example. Pressing EFI will insert the following
micro template:
\begin{figure}[h]
\centerline{\psfig{figure=«eps file»}}
\caption{«caption text»}
\label{fig:«label»}
\end{figure}«»
The text «eps file» will be selected and vim will be left in
select-mode so that the user can continue typing straight away. After
having typed in the file name, she can press Control-J (while still in
insert-mode). This will take her directly to the next "place-holder".
i.e, «caption text» will be visually selected with vim in select
mode again for typing in the caption. This saves on a lot of key
presses.
If you still do not feel like using placeholders, include let g:Imap_UsePlaceHolders = 0
in your .vimrc.

VIM: Respect only current code block

I have started working on a huge PHP application that has thousands of lines of code in each file, with lots of huge if blocks, classes, and functions all existing in the same file. I'm not the only dev working on it, so I cannot refactor!
I have tried using the Tags List plugin but it does not really help. Is there any way to have VIM respect only a particular code block, and ignore the rest of the file? I am hoping for some or all of these features:
Enable line numbering only for the current code block, starting from 1 at the line containing the opening {, and showing no numbering for lines preceding it or after the closing }.
Searching with / would be restricted only to the block in question.
I am thinking along the lines of selecting the current block and editing it in a new buffer when enabling the mode, then replacing the existing block with the edited block when exiting the mode. However, I am having trouble actually implementing this feature. My current version is this:
map <F7> <Esc>mO<C-V>aBy:new<Return>p:set nu<Return>:set ft=php<Return>ggi<?php<Return><Esc>
map <F8> <Esc>ggdd<C-V>aBx:bp<Return>`O<C-V>aBp
However, this has several issues, such as the inability to perform incremental saves.
I would be very surprised if Vim allows the kind of line numbering you ask for.
This plugin (and 1 or 2 similar ones IIRC) allows you to visually select a region of your current file, work on it in another buffer and put everything back in its place in the original file on :w.
Even if it's not the solution you are wanting, I think the following can help you to solve your problem.
You can use phpfolding plugin, which folds by PHP syntax (functions, classes, methods, PhpDoc...)
You can then select a fold by pressing v$ over the closed fold and execute whatever you want with :whatever. For example, :s/this/self/g to substitute all this for self in the fold. When you press :, vim will automatically add '<,'> to denote following command it's only for the visually selected text.

Resources