I use vim from time to time, when hacking stuff on my server. I often hear people say it's the best editor.
Could you tell me; don't you miss a mouse? Or a scrollwheel? Or alt-tabbing? Do you use a project panel wher you can see your files? Do you browse that with your keyboard?
I use vim and don't miss the mouse; I don't even have a scroll wheel (I much prefer a proper old fashioned 3-button mouse with a proper middle button).
A tags file and ^] and ^t to navigate is faster than file browsing and scrolling around. * and # to quickly jump between instances of the same token. ^6 to quick swap between buffers, and ^o and ^i to quickly jump back and forth between locations I've visited.
Fast cursor movement using b, w, {, }, /search, [[, ]], is also much faster than mousing around or slowly navigating using arrow keys.
Scrolling is done by ^e and ^y, and zz to center on the cursor. Faster than a scroll wheel.
And don't forget the almighty '.'. To quickly replace a variable name, stand on the variable, hit * to search for it and remember the search. Then 'cw' to change a word, type the new name, hit escape. Then 'n.' to find the next instance and repeat the edit.
Could you tell me; don't you miss a mouse? Or a scrollwheel? Or alt-tabbing? Do you use a project panel wher you can see your files? Do you browse that with your keyboard?
I don't miss the mouse or scrollwheel at all when using vim. HJKL, as nice as it is, is probably the least efficient way to navigate code with vim. You're much better off navigating by word or by using / to just search for where you want to go. Having regex search just a single keypress away is amazingly powerful once you start really using it.
As far as alt-tabbing goes, I'm not sure what you mean. I alt-tab in and out of vim all the time. If you're having trouble with that, then perhaps something is wrong with your vim configuration.
I do not use a project panel to browse my files. That's IDE thinking. Vim is a text editor, not an IDE. Unix itself is the IDE. If you want to browse/navigate files, you should be using the shell, not vim. If you want you file browser and your text editor in the same window, you should be using screen, or tmux, rather than hacking additional panes onto vim.
I suspect your problem is that you're not using vim enough. Learning vim is much more like learning a musical instrument than it is like learning a programming language. You can't expect to master the piano if you only play one hour a month. Similarly you can't expect to master vim if you only use it to edit the odd config file on your server.
I've been using Vim for a long time. I'm a sort of Vim heretic, I'd say. In that I'm mostly touch typing but I don't do the whole "fingers on the home row" or even GASP I don't navigate using hjkl. I've played too many games using the arrow keys or awsd to switch to some sort of weird in-line configuration of that.
Anyway:
1. Mouse - you can use your mouse with Vim.
set mouse=a
vmap <C-c> "+y
vmap <C-x> "+x
vmap <C-v> "+gP
There you go. Mouse actions + Ctrl-V Ctrl-C/X/V for easy copy-paste.
2. Scrollwheel - you can enable the scroll wheel, I can't test right now but I'm pretty sure you can use it. I move around more by Page Up/Page Down (another Vim heresy!) or by searching (a ton more common).
3. You can Alt-Tab using Vim. Just use Gvim. Or did you mean switching tabs with Ctrl-Tab? There you go:
map <C-Tab> <Esc>:tabnext<CR>
map <C-S-Tab> <Esc>:tabprevious<CR>
4. There's quite a few plugins for that. NerdTree, for example.
Anyway, don't feel forced to use Vim. I use it because it's cross platform, free and I'm used to it. But don't drink the KoolAid. It's not some magical weapon. Especially if your mental model doesn't match its model. For example in my case it matches only partially (see the whole arrow keys, copy-paste, mouse usage, etc.). But I still use it because I like the modal editing and to be honest, I think that for me command mode/ex mode is what keeps me using it. :s, :g, :tabnew & co. are too darn useful.
You've already gotten some good answers while I was finishing my coffee, but here goes anyway.
The only time I miss a mouse is when I want to fire up a game that actually runs on my Mac (Dwarf Fortress, Rimworld, etc.). I'd say the main reason I don't miss a mouse in vim is because I don't use a mouse anywhere else on my Mac. On a fresh format I create 4 desktops, and I bind CMD+1-4 to switch between these. Whenever I want to launch chrome/term/mail/whatever I use CMD+space and launch it directly from Spotlight. I use Magnet (http://magnet.crowdcafe.com - no affiliation, just a fan) to maximize/minimize/layout windows without having to use the _remarkably awful_ Mac window management UI.
While within vim I don't miss a scroll-wheel because bouncing around with / and ? is just so, so, so much faster. I really cannot stress enough how slow it now feels to scroll up and down a file searching for a specific string when I'm forced to do so. It's maddening for me now.
Your question re: a project panel, etc, is probably the best one. I think I may be an outlier here. I don't use NERDtree, but a lot (most, in fact) of my friends who use vim do. There are really two use cases for opening a file - direct from the term or in concert with an already open file. I typically know the structure of a project so I can just cd around or vim right/to/the/file.js If I'm already editing something I'll usually just :vsp to/the/other/file.erb or if I'm really lost as to where I am or where I'm trying to go I'll just CTRL+Z back to the term, cd & ag around until I find myself, fg back to vim, then :vsp to/where/I/now/know/Im/going.scss
I suspect if I actually spent the time to learn NERDtree I may be able to get around unknown projects better, but I've always felt pretty good about my workflow so I've just never committed to it.
As the GP alludes to, the key insight to becoming productive in VIM is the power of the movement system. To (mis)quote Gary Bernhardt, the slowest thing you can do is read something to find where you want to be. Searching is better, and better still is being able to just go straight to the place you want to go, even if it's in another file.
If you're using a file tree, you are probably doing it wrong. Instead, get used to tools like Command-T and the :vim command. Also set incsesrch and hlsearch. Once you learn how these things work, start making a conscious effort to play a bit of vim golf to get to where you're looking to be in as few keystrokes as possible. It's a bit painful starting out, but once you get over the hump you really will feel like the mouse is obsolete.
So I have Ctrl-P installed and I used it sometimes, but often I just use NERDTree to navigate to a file. I think my brain does a better job of retrieving the location of the file than the name of the file or module/class. I find it mentally less taxing to use NERDTree, even if it takes a few more keystrokes.
What, I have to move my hand off the keyboard, over the numpad, land on the mouse, register where the pointer is, move the pointer to whereever, do the action... and reposition my hand back on the keyboard?
Seriously though, you do start to edit faster in vim once you 'get it', and I'm not all that great with it myself. I have seen a vim god in action and I've never seen anything so fast at editing. This all being said, vim is much more suitable for system administration than developing, IMO.
Comments
I use vim from time to time, when hacking stuff on my server. I often hear people say it's the best editor.
Could you tell me; don't you miss a mouse? Or a scrollwheel? Or alt-tabbing? Do you use a project panel wher you can see your files? Do you browse that with your keyboard?
I ask because I always struggle in vim.
I use vim and don't miss the mouse; I don't even have a scroll wheel (I much prefer a proper old fashioned 3-button mouse with a proper middle button).
A tags file and ^] and ^t to navigate is faster than file browsing and scrolling around. * and # to quickly jump between instances of the same token. ^6 to quick swap between buffers, and ^o and ^i to quickly jump back and forth between locations I've visited.
Fast cursor movement using b, w, {, }, /search, [[, ]], is also much faster than mousing around or slowly navigating using arrow keys.
Scrolling is done by ^e and ^y, and zz to center on the cursor. Faster than a scroll wheel.
And don't forget the almighty '.'. To quickly replace a variable name, stand on the variable, hit * to search for it and remember the search. Then 'cw' to change a word, type the new name, hit escape. Then 'n.' to find the next instance and repeat the edit.
And this is why I read vim threads. I've been using vim for years, yet didn't know about ^O, ^I, ^E, ^Y or ^^.
That last in particular is going to be a big help. No more `:e #` for me!
While doling out vim tips, here are two quality of life improvements you can add to your .vimrc:
Ah, I'm one of those weirdos who actually uses ; (and ,). Though I guess I could
But that might take muscle memory too much time to adapt. (And would it break plugins?)I've already got F7 and F8 mapped, but I'll hunt out a spare key(sequence) for the mappings you suggest.
Could you tell me; don't you miss a mouse? Or a scrollwheel? Or alt-tabbing? Do you use a project panel wher you can see your files? Do you browse that with your keyboard?
I don't miss the mouse or scrollwheel at all when using vim. HJKL, as nice as it is, is probably the least efficient way to navigate code with vim. You're much better off navigating by word or by using / to just search for where you want to go. Having regex search just a single keypress away is amazingly powerful once you start really using it.
As far as alt-tabbing goes, I'm not sure what you mean. I alt-tab in and out of vim all the time. If you're having trouble with that, then perhaps something is wrong with your vim configuration.
I do not use a project panel to browse my files. That's IDE thinking. Vim is a text editor, not an IDE. Unix itself is the IDE. If you want to browse/navigate files, you should be using the shell, not vim. If you want you file browser and your text editor in the same window, you should be using screen, or tmux, rather than hacking additional panes onto vim.
I suspect your problem is that you're not using vim enough. Learning vim is much more like learning a musical instrument than it is like learning a programming language. You can't expect to master the piano if you only play one hour a month. Similarly you can't expect to master vim if you only use it to edit the odd config file on your server.
I don't miss mouse and scroll wheel because those are present in vim :)
To browse my files I use NERDtree, which acts like most project panels in IDEs, and yes I browse it using the keyboard.
Not sure what you mean by alt tabbing though.
I've been using Vim for a long time. I'm a sort of Vim heretic, I'd say. In that I'm mostly touch typing but I don't do the whole "fingers on the home row" or even GASP I don't navigate using hjkl. I've played too many games using the arrow keys or awsd to switch to some sort of weird in-line configuration of that.
Anyway:
1. Mouse - you can use your mouse with Vim.
set mouse=a
vmap <C-c> "+y
vmap <C-x> "+x
vmap <C-v> "+gP
There you go. Mouse actions + Ctrl-V Ctrl-C/X/V for easy copy-paste.
2. Scrollwheel - you can enable the scroll wheel, I can't test right now but I'm pretty sure you can use it. I move around more by Page Up/Page Down (another Vim heresy!) or by searching (a ton more common).
3. You can Alt-Tab using Vim. Just use Gvim. Or did you mean switching tabs with Ctrl-Tab? There you go:
map <C-Tab> <Esc>:tabnext<CR>
map <C-S-Tab> <Esc>:tabprevious<CR>
4. There's quite a few plugins for that. NerdTree, for example.
Anyway, don't feel forced to use Vim. I use it because it's cross platform, free and I'm used to it. But don't drink the KoolAid. It's not some magical weapon. Especially if your mental model doesn't match its model. For example in my case it matches only partially (see the whole arrow keys, copy-paste, mouse usage, etc.). But I still use it because I like the modal editing and to be honest, I think that for me command mode/ex mode is what keeps me using it. :s, :g, :tabnew & co. are too darn useful.
You've already gotten some good answers while I was finishing my coffee, but here goes anyway.
The only time I miss a mouse is when I want to fire up a game that actually runs on my Mac (Dwarf Fortress, Rimworld, etc.). I'd say the main reason I don't miss a mouse in vim is because I don't use a mouse anywhere else on my Mac. On a fresh format I create 4 desktops, and I bind CMD+1-4 to switch between these. Whenever I want to launch chrome/term/mail/whatever I use CMD+space and launch it directly from Spotlight. I use Magnet (http://magnet.crowdcafe.com - no affiliation, just a fan) to maximize/minimize/layout windows without having to use the _remarkably awful_ Mac window management UI.
While within vim I don't miss a scroll-wheel because bouncing around with / and ? is just so, so, so much faster. I really cannot stress enough how slow it now feels to scroll up and down a file searching for a specific string when I'm forced to do so. It's maddening for me now.
Your question re: a project panel, etc, is probably the best one. I think I may be an outlier here. I don't use NERDtree, but a lot (most, in fact) of my friends who use vim do. There are really two use cases for opening a file - direct from the term or in concert with an already open file. I typically know the structure of a project so I can just cd around or vim right/to/the/file.js If I'm already editing something I'll usually just :vsp to/the/other/file.erb or if I'm really lost as to where I am or where I'm trying to go I'll just CTRL+Z back to the term, cd & ag around until I find myself, fg back to vim, then :vsp to/where/I/now/know/Im/going.scss
I suspect if I actually spent the time to learn NERDtree I may be able to get around unknown projects better, but I've always felt pretty good about my workflow so I've just never committed to it.
As the GP alludes to, the key insight to becoming productive in VIM is the power of the movement system. To (mis)quote Gary Bernhardt, the slowest thing you can do is read something to find where you want to be. Searching is better, and better still is being able to just go straight to the place you want to go, even if it's in another file.
If you're using a file tree, you are probably doing it wrong. Instead, get used to tools like Command-T and the :vim command. Also set incsesrch and hlsearch. Once you learn how these things work, start making a conscious effort to play a bit of vim golf to get to where you're looking to be in as few keystrokes as possible. It's a bit painful starting out, but once you get over the hump you really will feel like the mouse is obsolete.
So I have Ctrl-P installed and I used it sometimes, but often I just use NERDTree to navigate to a file. I think my brain does a better job of retrieving the location of the file than the name of the file or module/class. I find it mentally less taxing to use NERDTree, even if it takes a few more keystrokes.
What, I have to move my hand off the keyboard, over the numpad, land on the mouse, register where the pointer is, move the pointer to whereever, do the action... and reposition my hand back on the keyboard?
Seriously though, you do start to edit faster in vim once you 'get it', and I'm not all that great with it myself. I have seen a vim god in action and I've never seen anything so fast at editing. This all being said, vim is much more suitable for system administration than developing, IMO.