One thing I've never been able to figure out in Vim: why does O (insert new line above the current line and enter insert mode) often wait and hang? And when you start typing, it'll sometimes do random stuff? Is there a way to just make it behave like a true counterpart of o (insert new line below and enter insert mode)?
A Vim Guide for Advanced Users
101–110 of 179 posts
Re: A Vim Guide for Advanced Users
#102Earlier quoted context omitted.
> is there a a way to close such that the previous file that was originally opened to return? If I understand the question correctly then the answer is ":bd" after ":w"riting the file. If you just want to switch between buffers (switch between the two files) then use ":b#". You can also list open buffers with ":ls" Someone recently told me of :tabedit, though, and that is lookin' way nicer to me. But I haven't gotten…
"Split screen" as in make a new window? Sure - `:vs` ("vertical split"), or `:vs filename.txt`. Or there's the "Windows" section on https://thevaluable.dev/vim-intermediate/ .
Re: A Vim Guide for Advanced Users
#103Nice, but still wondering if I should know vim since nano is enough for me :)
Can you tell me how to exit nano without writing changes? Every time some silly default server kicks me into nano I'm absolutely lost and ctrl+c doesn't give you help text like in vim iirc. (Not kidding)
Re: A Vim Guide for Advanced Users
#104The article mentions ”gn” in passing, but it doesn’t give it enough credit: this is an enormously useful motion, almost more useful on its own than the rest of the article. The thing that makes it golden is that it is a motion, and thus combined with a command, it is repeatable! So, like: 1. Search for something (either using / or *). 2. Type ”cgn” in Normal mode (i.e. change next search match) and replace what you s…
It's pretty comprehensive. Personally I'd just install Doom Emacs though :)
Re: A Vim Guide for Advanced Users
#105Earlier quoted context omitted.
I used to do n.n.n.n. to do the same (i.e. /search something, then do the replacing with something like cw or 3s or ct' or whatever you want, and then hit n for next result and . to repeat the change). Using cgn is less flexible and you need to learn another thing (you know about n and . already by the time you get to cgn), and maybe it's just me but hitting n. repeatedly is practically equally fast as just hitting t…
This might be the right audience for this little vimrc tidbit: "Press space to highlight current word nnoremap \ :let @/='\ =expand(" ") \>' :set hls This works just like *, except that it leaves your cursor where it is. You can then use n/p/whatever as normal.
Re: A Vim Guide for Advanced Users
#106One thing I've never been able to figure out in Vim: why does O (insert new line above the current line and enter insert mode) often wait and hang? And when you start typing, it'll sometimes do random stuff? Is there a way to just make it behave like a true counterpart of o (insert new line below and enter insert mode)?
Took some effort to refine a websearch: https://stackoverflow.com/questions/2158516/delay-before-o-o...
Instead, setting nocompatible and timeoutlen=1 (1ms I guess? Help file doesn't say) works fine in my terminal, I guess because it's not over any sort of network connection. I'll give this a go and see if I run into any issues when using these escape-based features (afaik I use those only rarely) over the network.
Re: A Vim Guide for Advanced Users
#107Earlier quoted context omitted.
Can you tell me how to exit nano without writing changes? Every time some silly default server kicks me into nano I'm absolutely lost and ctrl+c doesn't give you help text like in vim iirc. (Not kidding)
It's CTRL+X and then N to not save changes
Re: A Vim Guide for Advanced Users
#108Re: A Vim Guide for Advanced Users
#109Is there a good way by default to wrap a visual selection in braces/parens/brackets?
c()^[P or c(^r")
The first leaves you in normal mode the second in insert mode. I recommend vim-surround by tpope though.
Re: A Vim Guide for Advanced Users
#110 1. a
1. b
1. c
The post says to "select in VISUAL mode the last two lines and hit `g CTRL+a`". So I guess with shift+v select the bottom two lines, and then I hit g, space, and Ctrl+a. I get: 1. a
2. b
2. c
The post says that the last line should now start with 3 instead of 1, or in my case 2. The behavior is the same as when omitting g+space for me. Am I doing it wrong?