This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/surviving-your-first-week-in-vim
Iāve made the switch to Vim about a month ago. I was in love with Sublime, but I spend so much time in the console and on remote CLIs that it really warranted the switch. So far no regrets, the only minor complaint that I have is the 256 colour limitation, havenāt found a work around for that one just yet and it wouldnāt make any sense for me to use gvim over Sublime for reasons stated above. This means slightly less colour scheme options, but definitely not anything progress stopping.
For anybody using Sublime looking to make the switch but canāt quite wean themselves off: just to get your feet wet with the idea of less mouse interactions try working in full screen mode. They have various keystrokes that will allow you to navigate tabs/files just as efficiently as if you were to use your mouse. They even have a vim mode for sublime, I havenāt tried it myself, but perhaps a good introduction.
I switched to Vim two months ago thanks to Ben Orensteinās advice, and have become vastly more productive than I ever was using Sublime. Itās painful for the first 2 days, but stick with it, and you will have no regrets. After youāve been using it at least a week, check out tpopeās vim-rails plugin and Chris Toomeyās tmux trail on Upcase.
One drawback, when starting to use Vim, is that you start using the Vim key shortcuts in other programās too. Every now and then I catch myself wanting to use the direction keys (hjkl) in my email client, or some other sofware tool. Anyone else had that experience?
Hey all; we have some great additional Vim resources on our Youtube Channel from various meetups weāve filmed. Enjoy!
Yep, vim
has worked its way so far into my muscle memory that I try to use its key mappings everywhere such as when typing a url into the address bar or writing an email or GitHub comment, hammering esc wondering why I canāt delete 2 lines at once hah
Yes. Same here. Great that Chrome has a āVimiumā extension that uses Vim motion commands.
Besides, if you use Gmail via web they also have ājā and ākā.
The cheat sheet is great! Iām curious about one thing I saw: _ is labeled as āsoftā bol down, but when I try it out, it seems to do the same as ^ - going to the first nonblank character on the current line and not the next line. Is something wrong with my configuration or is that expected behavior?
Hi @benorenstein and @christoomey Thanks for the encouragement!
Iāve had a on off love affair with vim for about 10 years and have finally now just started using it as my only editor! So thanks to Ben who first awed me by showing off mad vim skills in his talk at the RubyBath Conference and then Chris for introducing tmux!
one thing that I found really useful have the http://vim-adventures.com/ game. It really kept challenging me! (although it was difficult to convince my managing director that it was training for work). Also one other thing I wanted to add was instead of pressing Esc
I use Ctrl + c
to exit INSERT mode. It makes such a big difference, specially if you map the CapLock
key as a Ctrl
as well! It keeps my on the home row a lot more i find .
@benorenstein while at the BathRuby conference you were showing off how to run tests with vim and how the pane should hide itself if all tests are passing. I manage to run the tests with vim-rspec, but was hoping you could reveal the secret of auto-hiding the pane if its all green and display the failure?
Many thanks, and keep it up!!!
ā Hassan
Hey @hass_isnull, the plugin @benorenstein used in the video is vim-dispatch from tpope. It handles running commands from Vim and will detect and use tmux if present.
@christoomey what is a best way to configure vim so it can copy/paste from Tmux and iTerm? I still havenāt found a good solution to do soā¦ I thought you wrote an article about it a while ago. Does it still apply?
Hey @antwonlee, the post I wrote about tmux copy and paste is still relevant and is in fact how I copy and paste in tmux.
Iāve seen a number of people who connect Vim to the system clipboard, e.g. how @gabe does in his dotfiles by using the unnamed
clipboard.
Personally I like the clipboard interaction to be more explicit, so I use the following to set up pasting:
nnoremap <leader>p :r!pbpaste<cr>
And a plugin I wrote to allow copying to the system clipboard via text-objects and motions, vim-system-copy.
@christoomey you are a true tmux jedi master. It is working and it just changed my life.
Hey @christoomey, thanks for this, itās a much better binding than the one I was using before.
I know I can use :!
to call any shell command, but what does :r!
do?
@antwonlee thanks for the kind words!
@aaronmcadam in general :r
is short for :read
which will read in the contents of a file. :r!
or :read!
will read in the output of a shell command, e.g. :r! ls
will read into the buffer the output of ls
.
Ah, thatās really cool, thanks!
@christoomey, slightly related question:
I have had zero luck finding this in the vim documentation or on Google, so apologies if thereās some easy source Iāve missed.
Is there a way to send a command with arguments to :read!
? Iām trying to build a vim alias to paste a timestamp using the shell date
command in a file, but date
takes an argument, and I canāt seem to get the quoting or backticks right. Iād like to do something like this:
inoremap <C-t> <C-o>:read! date +%Y%m%d%H%M%S<CR>
but Iām not having any luck.
Hey @geoffharcourt,
No easy source that I know of. For this I would use the expression register rather than trying to use :read!
. The expression register is activated by typing <C-r>=
in insert mode (<C-r>
waits for a register to paste from, =
goes into the expression register sub-mode). You can then use system()
to call out to date
. All together as a map (with a substitute
to chop off the trailing newline):
inoremap <C-t> <C-r>=substitute(system("date +%Y%m%d%H%M%S"), '\n$', '', '')<cr>
@christoomey, works great, and now I know something new. Thanks again.
Hey all, does anyone have the link for the fuzzy search plugin mentioned?
Thanks for your help!