Search in cygwin window buffer of Mintty - cygwin

How to do a text search into a cygwin window buffer ? Is there a way to make the same kind of text seach as in Windows console buffer (right-click > search) ?
(I use mintty)

In mintty, you can do that using the sequence Alt+F3.
More information in the mintty man page
Searching in the text and scrollback buffer
Alt-F3 opens a search bar with an input field for a search string. Matches are highlighted in the scrollback buffer. Enter/Shift+Enter find the next/previous position of the match and scrolls the scrollback buffer accordingly. The appearance of the search bar and the matching highlight colours can be customized.
Beware this sequence is very close to the infamous windows sequence that closes a window. (which uses F4)
Alternatively, you can enable the Ctrl+Shift+H shortcut by going into the options pane of mintty and enabling Ctrl+Shift+letters shortcuts in the Key section of the options.
You access the options pane by right-clicking the mintty icon of the mintty window (upper left corner)

There's no such function currently. The closest alternative is to 'Select All' (followed by 'Copy' if you've disabled copy-on-select), paste into a text editor, and search there.

You have a few options.
Use cmd | tee file, then search in the resulting file afterwards.
Use screen's copy/scrollback mode.

(Mintty) I'd mucked up an rsync command (wrong direction) so I wanted to track which files had been altered. So I manually selected the Mintty screen output from the bottom with my mouse hold left mouse button and then push to top of the screen and then tediously waited while the screen scrolled forever backwards then when I'd gone back as far as I needed I did a Control-Insert to copy. I then pasted into a text file which I could then search, edit, grep, vim to my hearts content. Don't know if this the only way but it works!

I used emacs editor as buffer. From emacs open shell : C-x shell, then I can do search within buffer as current window.

Related

How to copy texts from multiple pages in Vi editor

I am opening the file in VIM editor.I am trying to copy a text which is present in multiple pages. At a time maximum I can select the text that is visible only on the current page when I open the file in vim editor. Is there a way to extend that selection to multiple consecutive pages?
I'm guessing you try to select the text with your mouse, and by the looks of it, you didn't enable mouse support...
If I'm right, the easy fix is to enable mouse support:
:set mouse=a
(see :help mouse)

copying text with the mouse in VIM, why doesn't it work?

I am using both MacVim and console Vim.
My shell is ZSH and the terminal is iTerm2.
What I am trying to achieve:
when I'm dealing with the GUI, in other window, sometimes I want a quick copy paste from a VIM window.
I can use the mouse to select the text, but:
cmd-c doesn't copy
ctrl-c doesn't copy
ctrl-shift-c doesn't copy
right button context menu copies sometimes but not always and I don't know why. I don't know if it's related to the mode I'm in, etc it's just not reliable. At this stage, the menu that appears in the console is not VIM's, since it doesn't have one, but iTerm2, so things get very confusing.
when using MacVim, the menu shows me to use cmd-c to copy, but whether I do it, or using the context menu it sometimes works and, more than often, it doesn't.
Reading from forums, I've tried to do:
:setmouse=a
but, when I press return it doesn't even acknowledge the line.
So, my simple question is: how can I do quickie copies from a mouse selection in VIM to paste it in another window without have to do anything else that would slow me down?
The command is
set mouse=a
but you need clipboard interfaces. See :help "*
I would visually select (with or without mouse) and use "*y, or :yank * if it can be done linewise (sometimes the range is easier to type, like :%y*).
Alternately, disable mouse-reporting (Cmd-R on mac) and use the native copy-paste.

What has changed my mouse selection behaviour?

In using vim on Linux at the terminal I expect mouse selection to behave as (e.g.):
Start insert mode
Select some other text with left mouse button
Click middle button
Selected text gets pasted in where I was inserting
I think of this as "normal terminal mouse behaviour", and expect it to work like that for all programs, not just vim. However, something changed in the past few days and vim now acts differently:
Start insert mode
Select some other text with left mouse button
My insertion point now moves to the start of the selection
My mode is changed from "Insert" to "(insert) SELECT"
Click middle button
Looks like nothing happened, but I think it has actually pasted the selection on top of itself, because if I click again the selected text appears a second time after the selection.
One other symptom: The mouse cursor is now an arrow when pointing at a vim terminal window. Other terminal windows show an I beam, and vim used to do that too.
This is a problem with vim, not terminal because
It behaves the same in Gnome terminal, Konsole, and Terminator
Other programs at terminal behave the "normal" way
I have tried changing settings for :behave, :set selectmode and :set mouse, but this has not helped (maybe I just haven't found the right combo yet?).
This problem is recent (this week), but I have not changed my vim settings relevantly in that time.
Any ideas as to what's going on here?
The command :set mouse=a suggested should enable mouse integration in all modes but this is not what you want. To stop VIM messing with the mouse settings use :set mouse= (with no letters after the equals) to prevent it from changing the mouse in any mode.

In Vim, can you show a tooltip where the cursor is?

Is there a way to display a tooltip (like a popdown menu, but just with text), where the cursor is, using VimScript?
If you mean a tooltip where the mouse cursor is, then you can do this by turning the ballooneval option on and setting the bexpr option to point to a function that returns your required tooltip. This is only available if you're using a vim compiled with +balloon_eval (see :version). Have a look at my (rather basic) tag balloons script for an example.
If you mean a tooltip where the normal vim cursor is, I don't think there's a very clean way to do this. You could create a custom menu with the text that you want (using amenu) and map the command to :nop<CR> and use :popup to display it:
amenu ]MyMenuName.The\ Text\ You\ Want :nop<CR>
popup ]MyMenuName
However, this will only work in the Win32 and GTK GUIs.
I don't know of a way to use the insert mode popup menu (the one used for Ctrl-P and omnicompletion etc) to just display some text. You could abuse the completion method to give your own text as the completion alternative and set menuone in completeopt to allow a single line to be shown, but it would probably overwrite the current text with the contents of the popup menu. It would probably also break omnicompletion!

How to jump back to NERDTree from file in tab?

I usually:
Choose the needed file.
Open it in a tab(t character, by default).
But how I can jump back to NERDTree to open one more file in a tab?
Temporary solution I use now in my .vimrc file:
map <F10> :NERDTree /path/to/root/of/my/project
But it's not very useful to start navigation again and again from the root directory.
Ctrl-ww
This will move between open windows (so you could hop between the NERDTree window, the file you are editing and the help window, for example... just hold down Ctrl and press w twice).
Ctrl+ww cycle though all windows
Ctrl+wh takes you left a window
Ctrl+wj takes you down a window
Ctrl+wk takes you up a window
Ctrl+wl takes you right a window
NERDTree opens up in another window. That split view you're seeing? They're called windows in vim parlance. All the window commands start with CTRL-W. To move from adjacent windows that are left and right of one another, you can change focus to the window to the left of your current window with CTRL-w h, and move focus to the right with CTRL-w l. Likewise, CTRL-w j and CTRL-w k will move you between horizontally split windows (i.e., one window is above the other). There's a lot more you can do with windows as described here.
You can also use the :NERDTreeToggle command to make your tree open and close. I usually bind that do t.
If you use T instead of t there is no need to jump back because the new tab will be opened, but vim's focus will simply remain within NERDTree.
You can focus on a split window using # ctrl-ww.
for example, pressing:
1 ctrl-ww
would focus on the first window, usually being NERDTree.
Since it's not mentioned and it's really helpful:
ctrl-wp
which I memorize as go to the previously selected window.
It works as a there and back command. After having opened a new file from the tree in a new window press ctrl-wp to switch back to the NERDTree and use it again to return to your previous window.
PS: it is worth to mention that ctrl-wp is actually documented as go to the preview window (see: :help preview-window and :help ctrl-w).
It is also the only keystroke which works to switch inside and explore the COC preview documentation window.
ctrl-ww Could be useful when you have limited tabs open. But could get annoying when you have too many tabs open.
I type in :NERDTree again to get the focus back on NERDTree tab instantly wherever my cursor's focus is. Hope that helps
The top answers here mention using T to open a file in a new tab silently, or Ctrl+WW to hop back to nerd-tree window after file is opened normally.
IF WORKING WITH BUFFERS: use go to open a file in a new buffer, silently, meaning your focus will remain on nerd-tree.
Use this to open multiple files fast :)
You can change the tabs by ctrl-pgup and ctrl-pgdown. On that tab you came from the NERDTree is still selected and you can open another tab.
In more recent versions of NERDTree you can use the command :NERDTreeFocus, which will move focus to the NERDTree window.
gt = next Tap
gT = previous Tab
if you want you can enable the mouse support editing ~/.vimrc file.
put set mouse=a
after that you enable files click in NERDTree.
All The Shortcuts And Functionality is At
press CTRL-?

Resources