Re:Vim Splits – Move Faster and More Naturally
by johncoltrane on Thursday April 18, 2013 @04:19PM
(#5572828)
It's worth noting that :vsplit can and should be shortened to :vs
Also, depending on how you like to work, keeping a stable working directory can be very useful:
:vs **/bar<Tab>
is somehow less mentally taxing than: :vs ../../models/bar.php
Re:Vim Splits – Move Faster and More Naturally
by thedufer on Thursday April 18, 2013 @05:40PM
(#5573297)
Can you point me to docs on in file searching? Those symbols are predictably hard to google. Based on a little messing around, it appears that * is what I expect from bash, and can also include directory separators.
Re:Vim Splits – Move Faster and More Naturally
by johncoltrane on Friday April 19, 2013 @04:06AM
(#5575462)
Google is not the right place to search for help: Vim comes with an extensive and easily searchable documentation.
:h **
is all you need to get your answer.
Re:Vim Splits – Move Faster and More Naturally
by BostX on Saturday April 20, 2013 @10:54AM
(#5581563)
Google helps when you don't exactly know what's the name of the thing you're looking for. That's in my case 85% of all searches.
Re:Vim Splits – Move Faster and More Naturally
by johncoltrane on Sunday April 21, 2013 @03:36AM
(#5584209)
You could try :helpgrep foo next time.
Re:Vim Splits – Move Faster and More Naturally
by thedufer on Friday April 19, 2013 @02:13PM
(#5577937)
Wow. I did not think vim help would deal with symbols well, either. Thanks!
Re:Vim Splits – Move Faster and More Naturally
by johncoltrane on Friday April 19, 2013 @01:05AM
(#5574966)
:h starstar
roughly means the same thing as -r or -R.
Re:Vim Splits – Move Faster and More Naturally
by saidajigumi on Thursday April 18, 2013 @02:26PM
(#5572191)
:vsplit .
On this point, it's worth noting that users of the NERDTree plugin[1] can set it to work with the above style of use as well: " Replace netrw with secondary NERDTree
let NERDTreeHijackNetrw=1
[1] https://github.com/scrooloose/nerdtree/
Re:Vim Splits – Move Faster and More Naturally
by Davertron on Thursday April 18, 2013 @08:35PM
(#5574068)
Thanks for this, I was searching for this exact thing the other day and couldn't find it.
Re:Vim Splits – Move Faster and More Naturally
by burntsushi on Thursday April 18, 2013 @01:52PM
(#5572007)
I love using splits, but your `set autochdir` tip is amazing. I hadn't know about it before today. Thank you!
Re:Vim Splits – Move Faster and More Naturally
by amiorin on Tuesday April 23, 2013 @09:13PM
(#5599050)
If you like 'set autochdir', then you should try this plugin https://github.com/amiorin/vim-project
Re:Vim Splits – Move Faster and More Naturally
by JoshTriplett on Thursday April 18, 2013 @03:25PM
(#5572522)
Note that you can abbreviate :vsplit as just :vsp .
Re:Vim Splits – Move Faster and More Naturally
by doctoboggan on Thursday April 18, 2013 @04:32PM
(#5572903)
You can even drop the p (and spaces if you are using arguments) So to open a vertical split containing a file browser in the current dir:
:vs.
I use this all the time.
Re:Vim Splits – Move Faster and More Naturally
by grayrest on Thursday April 18, 2013 @01:55PM
(#5572034)
My .vimrc used to have:
nnoremap - :Sexplore<CR>
Which opens netrw when you hit the - key. I now have it mapped to ctrlp instead (ctrl+enter in ctrlp to split open).
Re:Vim Splits – Move Faster and More Naturally
by adarshpandit on Thursday April 18, 2013 @01:21PM
(#5571843)
Nice! Someone shared a comment on the blog, `:Vex` and `:Sex` open a new split with an explorer, much like `:vsplit .`
`set autochdir` is very nice. Thanks for sharing!
Re:Vim Splits – Move Faster and More Naturally
by wahnfrieden on Thursday April 18, 2013 @01:48PM
(#5571975)
Isn't there some way of using % to open a file relative to the current one perhaps? To get the best of both worlds.
Re:Vim Splits – Move Faster and More Naturally
by alphard on Thursday April 18, 2013 @02:23PM
(#5572174)
I'm using the following to expand "%%" in command mode to the full path of the current open file's directory:
cabbr <expr> %% expand('%:p:h')
You could also use :. instead of :p to get the relative path, see :help c_% and :help filename_modifiers
Re:Vim Splits – Move Faster and More Naturally
by wahnfrieden on Thursday April 18, 2013 @05:34PM
(#5573261)
Wow, elegant. Thank you!
This means you can do something like:
And when you're working in foo.php, you realize you need to make a change to the bar model, bar.php, you can simply do: Instead of having to do: Going beyond filesystem awesomeness with Vim and window management, you can also use it to easily create new files as you're going along. This is particularly useful for new projects where you're flowing along generating new models. Working on a model and suddenly realize you need to create another one? This will create the new file in your buffer and you can start typing. If you realize you made a mistake, simply close the pane without writing at the file will have never been written. This can also be handy when you need to type something out or keep quick notes. Have a little pane off to the side with notes about what you're working on. Maybe it's some numbers you need to keep in your head or maybe someone interrupted you with a request while you were knee-deep in terminal land. Let Vim be your flow and your editor.