
Commanding your text editor - aggarwalachal
http://blog.peepcode.com/blog/2012/commanding-your-text-editor
======
petepete
A nice introduction, although I'd be surprised if anyone who wasn't totally
new to development didn't know these already.

Also, 'Fuzzy file' searching in vim: <https://github.com/kien/ctrlp.vim>

~~~
johncoltrane
You would be surprised at how many people, programmers or not, experienced or
not, don't know those and other basic shortcuts. No wonder Vim's motions sound
like necromancy to so many people.

~~~
account_taken
It is true Vim requires commitment but once you get it, the motions and key
combination are logical.

As others have mentioned for fuzzy finding, use CtrlP. I also use FuzzyFinder
for quickly switching between many open files (buffers).

~~~
johncoltrane
No need to have two plugins that do the same thing, CtrlP does buffer
switching too.

While we are at it…

I never really used TagList or equivalent widgets in other IDEs/editors as an
outline of my code but rather as a navigation tool. :CtrlPBufferTag is great
for moving around in a large file. Same thing with :CtrlPTag for navigating a
project. I love CtrlP.

If the "you" is me you don't need to convince me at all: I'm a diehard Vimmer.

------
jheriko
I think its much more important to become good at using whatever text editor
is infront of you - i.e. learning the standard Windows/Mac shortcuts, instead
of becoming reliant on what I consider the 'old' style of text editor.

Yet to meet anyone using vim or emacs who is actually more productive than
me... the more productive people use Visual Studio, Xcode, Eclipse or whatever
else is infront of them.

Maybe I am wrong, but I think typing is probably 30% or less of the time I
spend coding... and thinking to make sure I write less code is probably more
valuable than typing faster, not just in saving me time, but in improving
stability and ease of reading code...

~~~
martinced
Editor war!

You are confusing non-expressive languages like C# and Java which needs lots
of "refactoring" and lots of boilerplate code (hence the need for code
generators which understand "patterns" and refactoring tools etc.) with
"productive languages", for a start.

Then your point is moot anyway: since quite some time there are vim
programmers using an Eclipse bridge and getting the Eclipse features right
from inside vim (it's called "eclim") and there's, of course, a port to Emacs
("emacs-eclim") which, despite only being used by a few people, works quite
well (I'm using it and getting the best of both world and for when I do
_really_ need to something inside that piece of underperforming bloat that
Eclipse is, I can just switch to it in a heartbeat).

But anyway, even without these Eclipse bridges, if you do really think that
someone using, say, Visual Studio to develop C# code is more productive than a
programmer using Emacs to develop Clojure code I'd like to have some of the
stuff you're smoking because it looks good ; )

To me the biggest issue with Eclipse / Visual Studio / IntelliJ is that their
"text editor" part is really terrible.

In addition to that, programmers do craft tools to make their life easier : to
me it's only logical that a programmer would want to be able to program his
editor.

I suggest to take a look at the "Emacs rocks!" series on YouTube to get a feel
of what's possible using Emacs.

To me a good example of a productive programmer using Emacs would be Rich
Hickey. He created the Lisp dialect Clojure _and_ then he went on to create an
amazing DB (Datomic) using Clojure. He knows about productivity...

Now of course if you're stuck in the C#/NHibernate/SQL hell working on apps
full of mutability and where it's close to impossible to reproduce state, I do
understand why you feel Visual Studio would be better. But I do really your
ability to "move fast" compared to people using more advanced technologies and
who are not stuck in the "design pattern" / ORM mindset...

~~~
Raphael_Amiard
> non-expressive languages like C#

C# is a quite expressive language in my opinion. And i'm quite versed in
Clojure, which seems to be your language of predilection. It does have limited
type inference and lambdas, which makes it a lot less painful than Java.

It really depends on the problem you have at hand anyway. But even if you have
a problem where you need a more functional approach, with immutable data
structures, you can use F#, which is an amazing language.

> But anyway, even without these Eclipse bridges, if you do really think that
> someone using, say, Visual Studio to develop C# code is more productive than
> a programmer using Emacs to develop Clojure code I'd like to have some of
> the stuff you're smoking because it looks good ; )

I use Visual Studio to develop C# code. I use Eclipse if i have to code Scala.
I use emacs if i have to clojure, i actually used it to develop
Clojurescript's Lua backend. Most of them have good vim bindings anyway, but
in emacs i prefer to use emacs.

C# with Visual Studio can be the most productive of languages, provided the
good use case. And you sound like you know nothing about what you're talking
about.

~~~
aerique
I can really recommend Evil mode for Vim goodness in Emacs!

<http://emacswiki.org/emacs/Evil>

------
jrajav
The "keys instead of notations" idea is neat, but it makes it a little more
difficult to visually parse, and more importantly, it ignores other keyboard
layouts. For such a small article it's not a big deal, but if this were a
larger list, I would definitely go with a more abstract representation.

------
kayoone
As long as my programmer idols Carmack and Persson use Visual Studio and
Eclipse respectively to produce amazing stuff, i dont really care about
changing to vim/emacs...besides i work mostly in statically typed languages
anyway, so i would miss alot of the IDE features for refactoring.

~~~
johncoltrane
Just spent half of the day doing AS3 in Eclipse. That was nice… thanks to the
Vrapper plugin. Once you go Vim, using any other editor is a nightmare.

Maybe that's just me but I would be incapable of choosing an
editor/IDE/smartphone/perfume/car/whatever because someone I admire uses it.
That sounds incredibly childish to me.

~~~
kayoone
> Maybe that's just me but I would be incapable of choosing an
> editor/IDE/smartphone/perfume/car/whatever because someone I admire uses it.
> That sounds incredibly childish to me.

That is not what i was trying to say. I mean that when reading HN with all its
Vim/Emacs hype one could get the impressions that you cant be an awesome
software developer without using vim/emacs. But some examples like mine might
help to check with reality.

Lots of what you read on HN is hype, be it vim/emacs, textmate, NoSQL, or some
form of super cool javascript framework that is currently fashionable. Its
good to know that there are still lots of devs in the real world, using proven
tools and being as productive/awesome as the people using the latest buzz.

~~~
sejje
Vim doesn't make me feel like John Carmack.

It just keeps me sane. It just saves me from "arrow, arrow, arrow, arrow,
arrow, backspace, backspace, backspace, backspace, backspace."

Editing python it's fine. If I was going to write c++, I'm sure I'd pick up an
ide. With a plugin for vim keybindings.

~~~
krallja
Not every textbox has Vim, so learn the basics of how to type in a standard
Windows textbox.

Ctrl+<L/R arrow> moves one word to the left/right Ctrl+Backspace deletes the
previous word Home takes you to the beginning of the line End takes you to the
end of the line Adding Shift to any of the selection operators will select the
word/line in question.

Now you don't have to press arrow,arrow,arrow,backspace,backspace,backspace
anymore.

~~~
spudlyo
On my Mac every textbox has emacs thanks to OSX's NeXT heritage. On my Windows
box every textbox has emacs thanks to XKeymacs[1]. That's one area where I
think emacs users have a leg up on Vim users, our editing style can be
configured to work almost everywhere you input text.

[1] <https://github.com/fujieda/xkeymacs>

------
tubs
If you are deleting a word in order to correct a mistake (ie/ by typing it
back in) it's usually best to `cw` or `cb`, which will leave you in insert
mode after the delete.

------
welp
For some more modern auto-complete functionality in vim, clang_complete is
worth a look: <https://github.com/Rip-Rip/clang_complete>. It uses clang for
intelligently auto-completing C and C++, and I am constantly surprised that
more people haven't heard of it.

------
michaelfeathers
I hardly ever use 'delete word' because I use 'change word' so much.

~~~
clarkm
Yeah, I think that both 'change word' and either the 'change inner word' or
'change a word' ('ciw' and 'caw', respectively) should have been included. I
find myself using the last two modifiers much more often than 'change word' by
itself. I hope that's not a symptom of inefficient vim usage.

------
goldfeld
The other day I was thinking about how Sublime Text's Ctrl+P's great usability
could be extended to more use cases, and I began wondering,

1\. Why doesn't it already index on the function names (the ones you get to by
pressing @), so that I could find a file not by it's name or path, but by it's
function definition (and with less priority, by it's function use)?

2\. Why doesn't find in files work with the same usability, even if the match
would not be as instant? Having an overhead box and the file auto open in the
buffer as it matched would be a great improvement over what seems like a set
in stone standard of opening a new dialog/file to display the find in files
results.

If anyone knows of settings, plugins or even other editors I can get for these
features, I'd be in heaven.

------
scrumper
Good article, I feel rather foolish for not knowing the delete whole words
stuff; I have the feeling it's going to be a big step up in productivity for
me.

There's project-wide fuzzy opening in Xcode too: bind "Open Quickly" to
whatever you like (I use cmd+O). It has the same fuzzy searching as Sublime
Text (for example, gvcm will take you straight to your GridViewController) but
builds on it can take you straight to symbols if you want.

------
cocoflunchy
A few missing things from Sublime users:

Ctrl/Cmd + P is even better than fuzzy search in Sublime; it searches in all
the files that are contained in opened folders.

Automatic indentation is also available without plugin, though you have to add
a key binding:

    
    
      { "keys":  ["ctrl+shift+r"], "command": "reindent" , "args": {"single_line": false} }
    

or look for it in Edit > Line > Reindent.

Completion works with Tab too on Sublime.

------
hmart
I love Peepcode screencasts, the Vim series is great, They should release a
Sublime Text one. Meanwhile this TutsPlus free course about ST2
[http://net.tutsplus.com/articles/news/perfect-workflow-in-
su...](http://net.tutsplus.com/articles/news/perfect-workflow-in-sublime-text-
free-course/)

~~~
gits1225
I have tried watching a couple of peepcode videos, but at some point, sooner
or later, I invariably fall to sleep no matter how interesting the topic they
present is. Somehow the videos feel lifeless and monotonous. Maybe its just
me, but thats been my experience.

------
eitland
Regarding the point about autocompletion: If autocompletion is needed don't
use vim or emacs, -use Netbeans or eclipse, both excellent, free (both ways)
and open source.

vim is great and I use it all the time but not for Java and PHP where the IDE
support is so good that it really makes a difference.

~~~
exDM69
> If autocompletion is needed don't use vim or emacs, -use Netbeans or
> eclipse, both excellent, free (both ways) and open source.

Vim also contains excellent autocompletion (several kinds, actually, most
powerful of which is the omni complete) but it's not restricted to one
language. It may, however require you to install your language specific
plugins. Vim ships with C and C++ mode, which requires you to build a ctags
database of your source code. In addition you might want to add cscope for
source code navigation.

Eclipse has autocomplete perhaps for a handful of languages but Vim has
support for autocompletion in tons of languages.

In addition to omni-complete, vim can have an user defined completion (C-x
C-u), which is handy to set to do syntax completion (set
completefunc=syntaxcomplete#Complete). Vim ships with tons of syntax files,
which are used for completion and syntax highlighting. This is not super
useful for programming, but is excellent for different kinds of configuration
files, so you don't have to memorize (or look in the manual) for the
configuration options you use.

And I'd rather use Vim without autocomplete than have to deal with Eclipse.
Thankfully I don't have to.

Emacs has great autocomplete too.

~~~
priomsrb
I like to use eclipse with the vrapper plugin. That way I get the completion
and refactoring of eclipse as well a decent set vim key bindings. Vrapper may
not perfectly emulate vi/vim but it does the basics well. And when I need to
use advanced vim features (eg macro magic) I just open the file in vim.

To me the IDE features make up for the minor annoyances of using vi/vim
emulation.

------
netghost
I have to say, I really enjoy TextMate's autocomplete word. It's not fancy,
but it saves me tons of time.

Also, not listed there, but TextMate's autocomplete word can also be used with
[Shift - Esc] for the reverse direction.

~~~
iamjs
For vim users, Gary Bernhardt's vimrc has a nice little snippet to map the tab
key to perform completion if the cursor isn't at the beginning on a line.

[https://github.com/garybernhardt/dotfiles/blob/master/.vimrc...](https://github.com/garybernhardt/dotfiles/blob/master/.vimrc#L126)

You use tab for completion in so many other contexts, it's nice not to have to
break that habit in your editor.

------
darkgray
ST2 can also delete entire words: Ctrl+Del (ahead) Ctrl+Backspace (behind)

Ctrl+Del even works in Notepad, if that's your thing.

