yy
Copies the current selection, or, if there is no selection, the current line
Nope, if you've already selected something that's going to leave you in the one-y-received-now-please-indicate-the-object-you-want-to-yank state. It's absolutely critical to understand the verb-object grammar of Vim, and understand how visual mode interacts with that. Don't memorize permutations of y, just memorize how to move, and the fact that y yanks. </rant>
This is a really good overview. I've only been using VIM full time (more or less) for about a year so I know there's still a lot to learn. Every article has a little hint in there somewhere. I didn't know about moving lines up / down like that.
Nice! I just recently switched from Sublime to Vim... this will come in handy!! I've been trying to figure out how to do "Move selected text up" in Vim... Thanks!
Why are people moving to vim? I've used it for a long time, but mainly because used vi back in the late 80s, and it was the most familiar cross-platform style of editor at the time. I don't think it's that much more (or less) powerful than the other really good editors (Emacs included).
TextMate seemed really awesome, as did BBEdit, so why not stick to what you know?
1) Ubiquity - it works on OS X, Linux, Windows, etc. No matter what platform I am working on, I can have a common editing platform. I own a BBEdit license, have used TextMate, Sublime, and Ultraedit in my Windows days, but for most tasks I now use Vim because it is the same everywhere.
2) Speed - Closing out 1 year of working in a terminal more than a UI (from a decade prior of working with Windows), I am finding Vim more "convenient" (edit: another comment uses the term "efficient"). I am by no means an expert, but moving text around in Vim feels faster. It takes time to master, but I am finding value in the effort.
I still prefer GUI based editors for certain tasks - visual diffs for example (BBEdit, Cornerstone), and use a GUI for database development (DbVisualizer for schema browsing and simple ERDs), but plain old Vim is becoming a habit.
Whenever there's a Vim article on HN, the same questions and comments appear. Is Vim really all that? Isn't it really old? I'm already using BBEdit/Textmate/Emacs/Notepad++/Sublime Text/the editor du jour - is it worth it to switch?
Even though I have several different editors on my Mac, including ones I've paid for like BBEdit, I've been pretty much using Vim exclusively for nearly 8-10 months and it's been great.
I started to get interested in Vim last year because of all of the blog posts from folks looking to switch from Textmate for a variety of reasons. And since Textmate was THE editor on the Mac for quite some time, I was curious why accomplished developers were moving away from it.
Of the many things I like about Vim, the one that sticks out for me: there's no ceiling on what it can do and what you can do with it compared to other editors. There's an internal consistency about it that I appreciate--the Vim "language".
>TextMate seemed really awesome, as did BBEdit, so why not stick to what you know?
I think the problem with Textmate is that it appears to effectively be abandon-ware. I and many others are skeptical that a final, complete version of 2.0 will ever be released, and the source-code dump makes it seem even less likely. Second-system syndrome is alive and well.
In general, it's not a good idea to continue investing time and effort in software that will eventually cease to be available or updated. Given the persistence of vim and emacs, it seems unlikely that either will be abandoned in any reasonable short- to medium-term timeframe.
I hated DW's bloat and I knew how to write HTML/CSS/JS by hand so I turned to what was considered the top text editor on Mac OS 9 at the time. I liked it and used it for a few years until I upgraded to Mac OS X. At that time, I simply fell in love with the command line and the beauty of TextMate's snippets and Cmd+T and many refinements. The love story quickly turned into boredom and TM soon took the road to nowhere. This happened at a time I wanted to switch to Linux full-time so I spent a year trying every cross-platform editor/IDE I could find. I finally chose Vim which blew my mind and still does at time.
I moved to Vim from TextMate during a period of my life wherein I was only developing on a 13" Macbook, and found that the amount of screen real estate required to run my terminal for testing, TextMate, and my browser to be unacceptable. With Vim I could simply run it in the terminal, split my screen with TMUX, and run my tests.
I've stayed with Vim because I find it has very efficient means of manipulating text, and tends to stay out of my way. I feel encumbered when using Sublime Text 2, or TextMate (though less so with the former).
This was my question as well. I have seen it a lot. I understand it for people that have vim ingrained in their fingers (muscle memory).
I do not understand the reason for this at all for people who don't know vim. There are plenty of other editors that are just as feature rich, if not more so (Sublime and PSPad come to mind). Also, if you need the GUI based macvim, you lose the most important feature of vim and the actual main reason for its popularity today: the ability to edit files locally or remotely inside a shell that supports only text.
Then again, choosing inferior technology is actually quite common these days, as the widespread use of Rails easily demonstrates.
Sadly, this article never tries to teach Vim from a language standpoint, in which you use verbs and objects to describe text manipulations. It just gives some god-given key sequences resulting in the same actions as in Textmate but without any explanation why things are happening.
[+] [-] tsm|13 years ago|reply
[+] [-] jlgreco|13 years ago|reply
If you need to save before opening another file, then you should add set hidden to your ~/.vimrc
It is a crime this isn't the default.
[+] [-] aidos|13 years ago|reply
[+] [-] macbony|13 years ago|reply
[+] [-] adambrod|13 years ago|reply
[+] [-] tmister|13 years ago|reply
nnoremap <silent> <leader>sw kddpk
After that press ,sw to move the line upward.
[+] [-] pyrotechnick|13 years ago|reply
http://www.sublimetext.com/docs/2/vintage.html
https://github.com/sublimehq/Vintage
If you're fortunate enough to be using Sublime on OSX, finding a shortcut is easy as:
1. Opening the help menu - "Command-?" (Command-Shift-/) 2. Entering search terms
Here's a screengrab of the process for your particular query (moving lines up): http://i.imgur.com/j226q.png
And here's a screengrab of CheatSheet (http://cheatsheetapp.com), a utility for quickly reviewing shortcuts in any OSX app, being applied to Sublime: http://i.imgur.com/HPUB4.png
Alternatives for these are available for other platforms, should you not be using OSX. Seek and you shall find :)
[+] [-] wildgift|13 years ago|reply
TextMate seemed really awesome, as did BBEdit, so why not stick to what you know?
[+] [-] bsg75|13 years ago|reply
2) Speed - Closing out 1 year of working in a terminal more than a UI (from a decade prior of working with Windows), I am finding Vim more "convenient" (edit: another comment uses the term "efficient"). I am by no means an expert, but moving text around in Vim feels faster. It takes time to master, but I am finding value in the effort.
I still prefer GUI based editors for certain tasks - visual diffs for example (BBEdit, Cornerstone), and use a GUI for database development (DbVisualizer for schema browsing and simple ERDs), but plain old Vim is becoming a habit.
[+] [-] alwillis|13 years ago|reply
That's when I post links to articles like "Why, oh WHY, do those #?@! nutheads use vi?" http://www.viemu.com/a-why-vi-vim.html and "Coming Home to Vim" http://stevelosh.com/blog/2010/09/coming-home-to-vim/, "The vim learning curve is a myth" http://robots.thoughtbot.com/post/13164810557/the-vim-learni..., etc.
Even though I have several different editors on my Mac, including ones I've paid for like BBEdit, I've been pretty much using Vim exclusively for nearly 8-10 months and it's been great.
I started to get interested in Vim last year because of all of the blog posts from folks looking to switch from Textmate for a variety of reasons. And since Textmate was THE editor on the Mac for quite some time, I was curious why accomplished developers were moving away from it.
Of the many things I like about Vim, the one that sticks out for me: there's no ceiling on what it can do and what you can do with it compared to other editors. There's an internal consistency about it that I appreciate--the Vim "language".
Articles like this one "Learn to speak vim – verbs, nouns, and modifiers!" http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-n... really brought the concept home for me.
[+] [-] jseliger|13 years ago|reply
I think the problem with Textmate is that it appears to effectively be abandon-ware. I and many others are skeptical that a final, complete version of 2.0 will ever be released, and the source-code dump makes it seem even less likely. Second-system syndrome is alive and well.
In general, it's not a good idea to continue investing time and effort in software that will eventually cease to be available or updated. Given the persistence of vim and emacs, it seems unlikely that either will be abandoned in any reasonable short- to medium-term timeframe.
[+] [-] johncoltrane|13 years ago|reply
I hated DW's bloat and I knew how to write HTML/CSS/JS by hand so I turned to what was considered the top text editor on Mac OS 9 at the time. I liked it and used it for a few years until I upgraded to Mac OS X. At that time, I simply fell in love with the command line and the beauty of TextMate's snippets and Cmd+T and many refinements. The love story quickly turned into boredom and TM soon took the road to nowhere. This happened at a time I wanted to switch to Linux full-time so I spent a year trying every cross-platform editor/IDE I could find. I finally chose Vim which blew my mind and still does at time.
Curiosity paid, in my case.
[+] [-] jherdman|13 years ago|reply
I've stayed with Vim because I find it has very efficient means of manipulating text, and tends to stay out of my way. I feel encumbered when using Sublime Text 2, or TextMate (though less so with the former).
[+] [-] lucian303|13 years ago|reply
I do not understand the reason for this at all for people who don't know vim. There are plenty of other editors that are just as feature rich, if not more so (Sublime and PSPad come to mind). Also, if you need the GUI based macvim, you lose the most important feature of vim and the actual main reason for its popularity today: the ability to edit files locally or remotely inside a shell that supports only text.
Then again, choosing inferior technology is actually quite common these days, as the widespread use of Rails easily demonstrates.
[+] [-] matthiasv|13 years ago|reply
[+] [-] vacri|13 years ago|reply
...
5. You’ve already learned the basics of VIM. If you haven’t type vimtutor in your terminal for a 20 minute tutorial.
--
It's not meant to be a newbie's guide.
[+] [-] iamartnez|13 years ago|reply
http://www.vim.org/scripts/script.php?script_id=1928
[+] [-] bla2|13 years ago|reply
cmd-c is "*yy in vim. Just yy writes to vim's internal clipboard, not to the system clipboard.
[+] [-] udp|13 years ago|reply
[+] [-] unknown|13 years ago|reply
[deleted]