VIM return to scrolling after "Type number and <Enter> (empty cancels)" - vim

Some times you have a long list of options and you have to scroll to the end or type q to get prompted with: "Type number and Enter (empty cancels)"
Is it possible to return back to scrolling? Some times the list is long and I want to see my options again before making a decision. Especially since you exit to the "Type number..." without warning. Or the only option after reaching this point is to exit and enter again?

Is it possible to return back to scrolling? Some times the list is long and I want to see my options again before making a decision. Especially since you exit to the "Type number..." without warning.
Unfortunately, you cannot get back to scrolling. The pager is very minimal and doesn't have this option, in fact it supports little to no customization. See :h pager or :h more-prompt to familiarize with the navigation commands inside a pager, which to some extent will help mitigate this.
Or the only option after reaching this point is to exit and enter again?
Yes, but there are faster ways that doesn't require you to enter the entire command again. Meet #: and g<
#:
typing #: in normal mode re-executes the last command you ran. This means, you can get back to the top of the pager in 3 keystrokes (<cr>#:) after you reached the end of the pager and in the colon prompt.
g<
Less useful in your specific use-case, but this is useful when you hit enter accidentally. Typing g< right after you hit enter in the colon prompt, will take you back to the end of the pager, with option to enter a number again.

Related

How do I check if nothing was typed in the previous Zsh prompt

In the zsh prompt, I have a custom script to display the amount of time the last command ran for.
I've got this working, but how do I check if the user entered nothing and just pressed "Enter" or "Ctrl + C", in the previous prompt?
In this case, I do not want to show the amount of time the user spent idle, as this is not useful information for me.
$history[$((HISTCMD-1))] doesn't appear to work in this case. If the user typed nothing and just hit enter, it will just show the last command that was run, and not be an empty string.
If you define a function with the name zshaddhistory, it will be invoked every time enter has been pressed. $1 is the command being entered, and this can also be an empty command. You could set a global variable to indicate that an empty line has been entered, and use this variable later on.
Be careful with the return value from this function: If it returns 0, the command is saved into the history; otherwise it is not. You find more on this in the zshparam man-page, where _HISTORY_IGNORE_ is described, because the main use of this function is to control whether or not a command should be added into the history. Hence, an alternative would be to add empty lines to the history too and use your original approach with $history to access it. This has the disadvantage that seeing empty history entries is not really user-friendly.

what is the "count" in vim?

Seeing the help of vim I have problem to understand what refers the word count I see it many times while reading the manual:
i Insert text before the cursor [count] times
It would be awesome if you give an example for it.
Vim's "Count" allows you to repeat an operator or command several times. For example, if you are on the first cursor of this line:
Hello world, how are you?
And you type dw you will have
world, how are you?
Rather than typing dwdwdwdw, you may simply type 4dw or d4w and you will have
are you?
More specific to your example, you may type something like 5ihello<esc> and this will insert
hellohellohellohellohello
Like Kevin said in a comment, you can read up more in the help docs with :h count, which says:
*count* *[count]*
[count] An optional number that may precede the command to multiply
or iterate the command. If no number is given, a count of one
is used, unless otherwise noted. Note that in this manual the
[count] is not mentioned in the description of the command,
but only in the explanation. This was done to make the
commands easier to look up. If the 'showcmd' option is on,
the (partially) entered count is shown at the bottom of the
window. You can use <Del> to erase the last digit (|N<Del>|).
Just in case somebody is wondering how count plus insert works, you have to type a number before pressing i, then it will enter in insert mode, where you can type what you want, after you press esc to go back to normal mode, it will repeat count times what you typed.
Can you provide a link to the place in the documentation where you are confused? I would have posted this as a comment instead of an answer, but my reputation is not high enough. In attempting to answer your question without clarification:
Usually [count] can be substituted with a number.
For example; consider the delete command d. If you position your cursor in the middle of a text line and type :d[count] (ex: :d4) then press an arrow key (left or right arrow); you will end up deleting [count] (e.g. 4 characters) in the corresponding direction of the arrow key.
In the case of insert I am not sure to what the argumentcount is referring.
EDIT: I forgot to mention that you must hit the enter key after :d4. Then press the left arrow key. Of course, in order for VIM to realize that you are entering a command you must exit insert mode by pressing the esc key prior to entering the command :d4.

how do I toggle between modes in linux less

After typing this command
less +F file_name.data
I am able to see a file as data is being written to on the fly. This is great but after the data has been fed to the file, I would like to search around the file without leaving the file. Even after all the data has been written to it, it still says at the bottom of the screen "Waiting for data...(interrupt to abort)".
the phrase "Interrupt", to me, means CTRL+C or CTRL+Z but that is not right since I think it will take me out of the file complete. Instead, I think I need to just toggle between modes without leaving the editor. How do I do that?
Normally CTRL-C is trapped by less so that actually you don't quit from less but rather return to the "standard mode". If you don't like this behavior you can run less with -K option in which case less will exit after CTRL-C. By the way, please note that instead of run less +F file you can just hit F in "normal mode".
So to answer your question: you toggle between modes by pressing F and CTRL-C.

gvim What do the # symbols mean at the bottom left of the screen?

I've been getting used to using vim for the last two weeks and am really starting to like it. There's one thing I've been wondering about - sometimes when I'm typing something, these rows with nothing but the # symbol appear at the bottom of the screen:
This has happened a couple of times but I've never paid much attention to it, but I'm curious - like in that situation, pressing enter gets rid of one of them, and pressing enter again gets rid of the other. Then another two enters after that, another # row appears. Does anyone know what they mean?
this usually happens when you open a very big file (or very long lines).
You can set display option to show all lines. (without showing those #).
lastline When included, as much as possible of the last line
in a window will be displayed. When not included, a
last line that doesn't fit is replaced with "#" lines.
e.g. in my vimrc, I have set display=lastline
if you want to know detail about it, check :h 'display'
This means you have a line larger than your terminal's height and width.

Word / Code Completion in VIM

I know that I can get word completion through CTRL+N & CTRL+P and code completion through omnifunc with CTRL+X CTRL+O. I additionally tried Supertab (very nice), because I'm used to TAB-completion. That all worked all right. I would like to see possible matches while I'm typing, so I also tried autocomplpop.vim, witch does just that.
What I like to accomplish though, would be a combination of both together with a little twist: I would like to see suggestions pop up as I type (just like with autocompop) but when I use TAB the word should be expanded only to the largest common match:
foo bar testor booze test baz teter
te<TAB>
After I type te in the 2nd line, the popup should suggest test, teter and testor.
When I press TAB, it should do nothing, because there is no more common ground than te. After I typed an additional s and press TAB, it should expand tes to test (because it is the smallest common ground) and to testor after a 2nd TAB.
Edit: I try to be more clear...
te<TAB>
should do nothing because "we" don't know if a 't' (teter) or an 's' (test, testor) should follow.
tes<TAB>
should expand to test (because that works for both - test and testor - and teter is no longer a possible match).
test<TAB>
should expand to testor (only possible match).
Well, the suggestions popup is just bonus, but I really would love to see the TAB behavior. Hope I don't get to esoteric here and you can help me out with some script-tricks or plugins to tame VIM to do just that.
:set completeopt=longest,menu,preview
maybe?
(I'm not sure if your statement
"when I press TAB, it should do nothing, because there is no more common ground than te"
conflicts with your later statement
"to testor after a 2nd TAB."
It seems to me that there's no more common ground than "test" at that point... Unless you mean the first tab goes to the longest common ground, and then the subsequent tabs cycle through the other matches, in which case you're after what I have above...)

Resources