4 ms·
One of my goals is to become a really good vim power user. I am not able to pick up all of these but one here and there. In the first command gf, once new fil
by jzer0cool 6y ago
One of my goals is to become a really good vim power user. I am not able to pick up all of these but one here and there.
In the first command gf, once new file opened and then closed (wq), is there a a way to close such that the previous file that was originally opened to return? At moment returning back to shell prompt.
Also curious if there is a way to open the file as a new split screen rather than replacing the entire window?
- lucb1e 6y ago> 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 used to it yet or know how to make it work with gf or other handy things. As for split screen, those are hotkeys I have yet to learn. If someone has an answer to that question, please reply here so the parent commenter and I both see it :)
- alex_smart 6y agowq writes the current file and closes the current window (which quits vim if you happen to be on the last window). The command to close the current buffer is :bd(elete). If you want to return to the previous file without closing the new file, you can just use :bp(rev) so that the new file also stays in memory. Relevant man page is available at :help buffers. >Also curious if there is a way to open the file as a new split screen rather than replacing the entire window? CTRL-W f Another remark: vim's shortcuts are organized in a way that you are often able to guess what the correct shortcut should be. CTRL-W is the common prefix for commands regarding split windows CTRL-W v/s for splits, CTRL-W CTRL-W cycle through windows. So naturally you can guess that CTRL-W f should be open file in split and CTRL-W ] should be jump to definition in split.
- deleted 6y ago[deleted]
- gnubison 6y agoThis is not an answer to your first question, but I find that Ctrl-O and Ctrl-I are much more useful for getting back to your previous location -- which is normally what I want.