5

I recently started picking up vi, going through some tutorials and trying to get used to it. But I still have some questions about it.

It seems to be nice for small one file changes, but as soon as I start to try doing bigger things it seems to be lacking. For example I'm used to have code formatting, import organizing, simple overview over all packages and other things that an IDE gives me. I saw some tutorials on how to use vi as an IDE, but it felt awkward at best.

Now I'm just wondering, what are the typical use cases for vi? Is it typically used to edit small files, or can it be used for larger projects? And if you use it in larger projects, how do you make it work? Or would it be a lot easier to use an IDE with vi keybindings?

Kevin Panko
  • 7,844
  • 19
  • 46
  • 58
Andreas Arnold
  • 519
  • 5
  • 11
  • 1
    Note that vi!=vim. Most linuxes come with vim or (vim-tiny) and I think OS X also comes with vim but I'm fairly sure bsds/solaris/possibly other *nixes ship with more basic implementations. Vim provides a lot more especially for programming while ssh/vi(m) into a unix box might force you to deal with vi(if its not a linux box) which still provides a lot of powerful text editing but no nice things like syntax highlighting. The old "beep repeatedly" and "break everything" seems to be much more applicable to vi then vim and can cause lots of frustration. – Roman A. Taycher Jun 05 '11 at 12:41

12 Answers12

24

People use non-IDE editors like Vi(m) for coding due to the following reasons,

  1. They are non-distractive, allows you to concentrate on the job.
  2. They do not clutter you screen area, offers you more code space
  3. They are faster
  4. They have better/faster/cooler text manipulation at the stroke of the finger
  5. You happen to move your hands out of the keyboard less to hold the mouse, drag it here and there and click.
  6. They also have the flexibility to support other tools like debugger, document viewer, etc.
  7. They also have ways to get things like code folding, etc.

For a normal programmer whose ideal work cycle is sit, write code, test, debug, more code, test debug.. Vi offers a simplistic yet powerful environment to get the work done faster and more efficiently.

For someone who had years of using some IDE, it might be like using some prehistoric tool, but once they have been through the initial days, then there is no looking back. They'd feel like there is no better thing.

Parthan
  • 477
  • 2
  • 13
  • 3
    Vim *is* an IDE without the mouse nonsense – pestilence669 Mar 19 '10 at 19:46
  • 5
    So people... 1) are too easy distracted 2) should get a bigger screen 3) should get a faster machine 4) are too lazy to learn shortcuts of a real ide 5) once again - are too lazy to learn shortcuts of a real ide 6) don't know how to install plugins to a real ide 7) want to enter cryptic settings commands to enable features they get for free with a real ide Just kidding - I like vi for small tasks and remote editing, but I wouldn't use it for real software development. – FRotthowe Mar 19 '10 at 19:49
  • 1
    @FRotthowe Shortcuts in "real IDEs" tend to be made by people who don't understand efficient keyboard usage. Both Emacs and Vim have several killer features that no GUI IDE has yet matched: 1) semantic, hierarchical shortcut organization (ala Vim's compositions, or Emacs' C-x/C-c/M-x prefix system), 2) A fully customizable shortcut system where customizations can trivially be shared and moved between systems, 3) A keyboard-based system for entering commands in a scripting language that drives all editor functionality and configuration. – John Whitley Feb 05 '12 at 00:13
  • @John I *love* vim's text editing and scripting capabilities, as well as the customizability. I just don't need that functionality for programming, where intelligent completion, semantic navigation (jump to super class, open call hierarchy) and a visual debugger is far more important - at least to me. – FRotthowe Feb 06 '12 at 13:47
  • @FRotthowe Excellent points, to which I agree. I'd say that the features you cite comprise the killer features of modern IDEs completion, navigation, tools integration (debuggers, GUI editors, profiling). I'd also add semantic manipulation (ala refactoring) to the list. Cheers! – John Whitley Feb 06 '12 at 18:52
12

Why, oh WHY, do those #?@! nutheads use vi?

Pawka
  • 2,434
  • 3
  • 24
  • 31
7

I've haven't done anything that you'd call a big project in python (only little test scripts), but I use Vim exclusively for writing large embedded C applications and I have never really felt the need for an IDE.

Vim is fast to start up, extremely fast to use and (with a bit of customisation) can do most things that an IDE can do. It'll do code completion, code auto-indentation and reformatting and it is very good at refactoring. The project plugin http://www.vim.org/scripts/script.php?script_id=69 makes it very easy to manage projects with lots of files and the taglist plugin http://www.vim.org/scripts/script.php?script_id=273 is great for browsing source code. It also allows you to have the C code open side-by-side with python code, assembly code and latex documentation without having to use a different tool for each.

Overall though, I think there is one really valuable thing that Vim gives you that very few other editors do and I would find it very hard to lose that: I can have a window split into three parts like this:

GVIM Split Window

Each of the subwindows can either show a separate file or (as in the screenshot) a separate part of the file. I imagine emacs can do this (although I could be wrong), but I doubt many IDEs can. This can be invaluable for refactoring and for referring to other parts of the file.

Glorfindel
  • 19,729
  • 13
  • 67
  • 91
DrAl
  • 64,451
  • 10
  • 98
  • 103
  • Netbeans can do that by simply dragging the tab and laying it wherever you want it, you can even customize where you want each window by simply moving it. – user103219 Mar 19 '10 at 20:01
  • That's interesting, thanks razass: I'd not come across any editors that could show multiple views of the same file before. – DrAl Mar 20 '10 at 13:01
  • +1 simply for the fact that the source in your example was "cscope", something that's been near & dear to my heart for 20 years. – Dan Jun 17 '10 at 03:56
  • I'm pretty sure eclipse(not if you want separate windows for the same file you need to right click tab and select new editor) can do that also kate(the kde editor). – Roman A. Taycher Jun 05 '11 at 12:34
  • @Roman A. Taycher: I've seen this recently and it's good to see that Eclipse supports it. I couldn't code effectively without it! It is a lot more involved in Eclipse: you right click the tab, select new editor, then figure out how to lay out the windows so that they're side by side. In Vim, you type `:vsp` (short for vertical split) or `:sp` (for horizontal) and it's done. – DrAl Jun 07 '11 at 12:45
6

I've used VI(M) and Emacs as my primary editors for years... I've tried switching to IDEs but find they can't get out of my way enough. I always end up back in VI(M) or Emacs after a while. One major reason is that I find my hands need to leave the keyboard too much in IDEs as they require the mouse too often... And I'm too lazy to setup my own shortcuts for everything.

beggs
  • 4,158
  • 2
  • 27
  • 30
3

Here's why I use it.

  1. it's fast to start up
  2. it's available across multiple platforms and is on all Unix machines
  3. it's fast to use (keystrokes for common operations, operations based around words/paragraphs etc.)

However, I use IDEs for large scale development work, since I can't believe they can be beaten for productivity, given their code-awareness and refactoring capability. I use Eclipse, but I plug a VI editor emulator into it. See this answer for more details.

Community
  • 1
  • 1
Brian Agnew
  • 254,044
  • 36
  • 316
  • 423
  • While you are right on the IDEs productivity - you can always install additional tools to enable your hands to never reach for the mouse. I know a .NET programmer hates the mouse and has his entire PC setup for keyboard use (even firefox & VS2008) – Audioillity Aug 21 '09 at 08:55
2

I saw some tutorials on how to use VI as an IDE, but it felt awkward at best.

There's one thing to do at the very beginning: throw your sense of aesthetics overboard. You will never get the same kind of graphical experience in VIM as you do in a decent IDE.

That said, VIM actually does offer many of the features of a full-blown IDE and has a lot of advantages besides. I use VIM for almost all of my developing work and all of my text documents (using Vim-LaTeX) – even though I've actually paid money for Apple’s office suite, iWorks.

There's one point that's still nagging me, though: I can't get IntelliSense to work. For me, that's a huge problem, especially when using languages such as VB, C# or Java, for which excellent IDE support exists.

So, the learning curve for VIM is steep but once you've passed a certain point it's everything but awkward. In fact, compared to VIM's editing experience, you will find that it's the IDEs that suddenly feel awkward because while they're good at bookkeeping stuff, they suck at editing.

Community
  • 1
  • 1
Konrad Rudolph
  • 482,603
  • 120
  • 884
  • 1,141
  • You do know about ViEmu right? Then you get Vim *and* intellisense. – Brian Rasmussen Aug 21 '09 at 08:58
  • @Brian: haven’t tried it, and I don’t use Windows any more. It’s also not the same since VIM thrives on the integration into the terminal, something that’s completely lost here. I like working with makefiles and bash scripts. – Konrad Rudolph Aug 21 '09 at 09:02
2

I frequently work on a remote system, programming for a cluster, or editing config files on a headless box. All of these could be done with a file transfer, a regular IDE, and another file transfer, but it is so much faster to just use VIM through SSH.

Karl
  • 8,158
  • 5
  • 27
  • 29
1

Vim is not very good at code awareness. What it is good at is text manipulation. It provides you with the tools for you to edit text, not to edit for you. If you just do "small" edits and don't read up on the occasional "vim commands you wish you knew" you'll never understand the power provided.

code formatting

Formatting is done with =. You can also point equalprg to an external program to do the formatting for you.

import organizing

Vim won't be able to remove unused imports but if you select the import lines

:'<,'>sort

simple overview over all packages

:vs .

This will open a vertical window containing the current working directory :)

In conclusion, vim can't replace your IDE but it will let you edit your text.

he_the_great
  • 6,195
  • 2
  • 29
  • 27
1

You can find it (or easily install it) almost anywhere - Runs on all systems that can implement the standard C library, including UNIX, Linux, DOS, Windows, Mac, BeOS, and POSIX-compliant systems.

The ability to log into a remote server and confidently edit a config file is priceless.

Ken
  • 71,088
  • 29
  • 81
  • 100
0

As usuall: Choose your tool depending on the work you have to do! ;-) I'm using Vim and Visual Studio. You don't have to choose only one.

  • If you need an IDE, use an IDE. Vim is made for text manipulation.
  • It supports any languages. Try to edit a Ruby script with Visual Studio.
  • Performance on large files is much better than for most IDEs. Try to analyze a logfile having 100k lines and more using your IDE.
  • It runs on many plattforms and you can use it via a remote console, if you have to edit files on a server.
  • ...

IDEs are specialized tools, which are good for problems they are made for. Vim is an incredible flexible and powerfull generall purpose tool.

Achim
  • 14,333
  • 13
  • 70
  • 128
0

This is obviously a hot topic so I'm going to give a list of reasons why I prefer IDE editor for coding. 1) I prefer to be able to fold sections of my code (I don't know whether Vi(m) can) without having to remember the command to do so or type it.

2) I prefer one click compile button/command as opposed to having to remember my compile command and it's library of options

3) I prefer the easier highlight copy paste operations without having to........ aah sod it!!

Well by now you get the picture. I'm not knocking Vi(m) I just think having your the elements and functionality of your coding environment visually represented makes for a clearer head and encourages exploration of options you may not know exists.

Dark Star1
  • 5,973
  • 13
  • 68
  • 110
  • The last paragraph would have been better presented as less categorical statements, describing what you do. Editors are a hot button for many people, and any statement about what you think a particular editor will do for everybody has the potential to start a flame war. – David Thornley Mar 19 '10 at 19:52
0

I much prefer vim over vi and prefer not to lump them together. Vim provides some features that are really handy and not always immediately obvious. Already mentioned was screen splitting. Also you may want to checkout ctags or exctags. These allow you to jump around the code base from within vim. I can place the cursor over a called method, jump to the definition, jump to a definition within that method, etc. Very powerful for tracing down bugs. Cscope is another similar program.

Vim will also allow you to run arbitrary shell commands within the environment and has powerful search and replacement features.

So an IDE will provide most of those, what will vim provide over a traditional GUI based IDE? That's easy, it runs on the CLI.

This allows me to login to my dev box, run screen (definitely something to checkout for the unfamiliar: http://www.gnu.org/software/screen/) and run multiple vim sessions within my screen session on my dev box. Now when I leave work for the day, I can leave my work session just as I left it, even while running builds. When I come into work the next day I can connect from my environment as if I never left.

Another reason to like vim or vi in particular, is that it can be found on virtually any Unix environment.

MattK
  • 1,175
  • 10
  • 13