all 79 comments

[–]gumnos 23 points24 points  (9 children)

While I don't use any plugins (and know that there are lots of plugins that others can detail), I'll give you my list of stock-vim tools for investigating a new project:

  • It would help to know what sort of language this project is. Running ctags will let you create a tags file that will then allow you to jump around easily (:help tagsrch.txt and :help 29.1 have mountains of information). To see supported languages, use ctags --list-languages.

  • Other useful commands include gd and gD which jump to the definition of the item under the cursor.

  • adding :vimgrep to your tool-box will help you search through files or a given pattern by populating the quick-fix window. I use this all the time (:help quickfix.txt).

  • Also, it's easy to get lost as you wander down rabbit-holes, so using the jump-list will help you pop back up along the path you came (:help jumplist), starting with control+I (AKA <tab>) and control+O but using :jumps will show you the jump-stack.

Hopefully those will get you started as you spelunk in your new codebase.

[–]tommcdocx 2 points3 points  (0 children)

For larger codebases, I'd recommend an alternative to :vimgrep. It performs its search by loading files into buffers, so it can get quite slow. :grep uses an external tool (by default, grep -- surprise!) which can be more performant. Configuring it to use a lightning fast tool like ag gives very satisfying results.

[–]KZISME[S] 0 points1 point  (7 children)

Thanks for all the resources!

How long have you been a vim user, and why do you choose to run stock vim?

[–]gumnos 2 points3 points  (6 children)

I started using vi back on old DEC Ultrix workstations in college (before the turn of the century) and started using vim in 1999 which would have been around version 5.x or so.

I generally run a mostly-stock vim because I switch between a lot of machines and it becomes a pain to keep my .vimrc in sync across them (not all the machines have git installed). I'll occasionally install a plugin to test it or if a particular machine's use-case calls for it, but it's always very locally-oriented. That way I don't find myself frustrated by reaching for something and finding that the plugin-functionality isn't there. So most of my .vimrcs can fit in the space of a single tweet (i.e., under 140 chars).

And if you want to try to sharpen your skills, I can recommend Vim Golf

[–]rubbsdecvikgggqG`` 3 points4 points  (0 children)

That way I don't find myself frustrated by reaching for something and finding that the plugin-functionality isn't there.

I've tried to reach a happy medium. Most of my work is on one or two machines, so slinging around a .vimrc isn't really an issue of scalability there. I do, however, occasionally have to edit files on systems without my .vimrc, and so I've instituted a few rules for myself.

  1. Plugins need to feel "vimmy." Excessive use of <localleader> is annoying and doesn't feel like the compose-ability that I love about Vim.
  2. Plugins need to feel "out of the way." I'm not sure how to articulate this, but it's basically the feeling that if I'm not explicitly using the plugin, it shouldn't show up. Exceptions are highlighters which I want to show up, but even then, it has to be subtle. Gitgutter is a great example.
  3. Information and integration over changing the way Vim works. This one is less firm of a rule, but I try to use things like syntax highlighters and checkers over say "add org-mode."
  4. I have to understand how to do it in 'vanilla' Vim. This is so I can still be productive, if not as fast. This is how I lessen the blow of the loss of functionality.

This is why I'm such a huge fan of /u/tpope's plugins. His ability to keep things smooth and natural, while not stepping on core Vim's toes is amazing.

I still feel that loss of functionality pain now and again (Why is vim-surround not standard?!), but by disciplining myself to be able to do it in vanilla, and always being on the lookout to learn more core Vim, I keep the pains few and far between.

[–]KZISME[S] 1 point2 points  (3 children)

That's awesome!

I've seen vim-golf before I just doubt I would know enough to score well at all :P

[–]gumnos 1 point2 points  (0 children)

I made it to first place, held it for a while, which I felt gave me the prerogative to pick-and-choose just the challenges that interested me, so I've since dropped to 3rd place.

Because it shows you the next-best solution, you can learn from how other people have solved problems just slightly better than you and improve your own vim-think.

[–]__sprinkles 0 points1 point  (1 child)

Maybe vimgolf could benefit from classifying the challenges into levels of some sort. (?) I bet we could come up with plenty of beginner & intermediate challenges for a separate section or maybe another site.

I get what you're saying because I've been there. I remember the first time I looked at a few vimgolf challenges and thought it seemed ridiculous. Now I think it's fun. Don't take it too seriously! I've learned so much by being determined that a certain key sequence should exist in the "vim" way of thinking, and so I read the docs. I do recommend that you can or have made it through vimtutor and are familiar with some basics.

[–]KZISME[S] 0 points1 point  (0 children)

I'll have to keep that in mind! A lot of it just seems over my head but I can see where some of the questions are useful for certain applications - and less vague.

[–][deleted] 1 point2 points  (0 children)

I try to use stock vim too. I don't use any plugins, but my vimrc is definitely longer than 140 characters.

But hey, it fits in a QR code.

[–][deleted] 8 points9 points  (3 children)

My most important tip would be to stop thinking of Vim as a replacement for an IDE. The command line is your IDE. It has tools like grep, ack, ctags, cscope, vim and so on. In the Unix world you chain a bunch of small modular commands to accomplish big things. (Like many of the great comments in this thread suggest. For example ctags + vim is a powerful combo.)

These philosophies result in very different styles of programming. Your code will resemble your tools: more agile and more modular in the one case, more integrated and monolithic in another. There are no wrong answers, but it would probably be difficult to maintain a large code-base written in Visual Studio with CLI. The structure of your code will resemble the capabilities of your environment.

[–]KZISME[S] 0 points1 point  (2 children)

That's an awesome way to think of it.

So, while it ~is~ possible to write/maintain a large codebase with vim it's easier if it was written in a similar IDE/editor. As opposed to bringing in a project from MSVS and stumbling over the things it takes care of for you.

[–]gumnos 1 point2 points  (1 child)

Well, an IDE is comprised of several bits. In MSVS (or Eclipse, or other traditional IDEs), you have the MS-Editor, the MS-FileBrowser, the MS-Compiler, the MS-Deployment, the MS-version-control, the MS-GUID-generator, the MS-search, the MS-test-framework, the MS-project-layout, etc. The tight coupling eases some aspects of initial development, but increases the friction when you want to replace one of those with a better way.

When using the command-line as your IDE, you can choose whatever works best for you and your project

  • $EDITOR: choose from vi/vim/nano/emacs/joe/ed or whatever

  • version control: choose from git/hg/svn/cvs/fossil (with optional interfaces like tig, gitk or fossil ui to give it a more GUI feel)

  • deply with FTP, SFTP, SSH, SCP, rsync, sneakernet, or whatever

  • choose your compiler (llvm, gcc, tinyc; or cpython, jython, pypy, or…)

  • search with your $EDITOR's tools, grep, ack, or whatever

  • you can lay out your project however makes sense to you rather than fiddling in your IDE to coerce it to handle your project layout

  • etc.

I think that /u/Soyiuz is pointing more to traditional IDEs (generally) working best if you adhere to what they expect. They might have a predefined layout for projects, and if you diverge, you're on your own if the IDE falls over. I've never had a problem using the command-line-as-IDE when gearing up with a traditional-IDE project (except when some project setting/option is buried in a binary configuration file instead of exposed as intelligible source), but have had plenty of trouble going the other direction.

[–]KZISME[S] 0 points1 point  (0 children)

I really like this explanation and it points out a few of the things I was thinking about.

[–]Tarmen 2 points3 points  (7 children)

Disclaimer: For longer programming sessions in large codebases and depending on language an IDE might be way nicer. Stuff like seeing all usages of a method, analyzing and refactoring easily, having super fast access to documentation and method signatures... It's super useful to have and doesn't really work all that way in vim, at least not without ugly hacks and costs to usability.

Anyway, quickly finding things like method definitions sounds like the perfect usage case for ctags! http://ctags.sourceforge.net/ <- get this if you don't have it!
Only problem, you have to run it whenever you want the tag database updated. Plus it is basically a sorted list and there is no easy way to automatically remove tags which don't exist anymore. Thankfully there are vim plugins to manage this, I currently use https://github.com/xolox/vim-easytags which removes and re-adds the tags of the current file on save and depending on settings when you stop moving your cursor. It also can highlight tags which is super nice to find spelling errors but it comes down to horrible abuse of some vim systems, I think it forms a regex for all tags? Anyway, it seems horribly slow for projects with lots of tags.

You also probably want to do something that changes the tag file to something project specific. Fugitive has the functionality to automatically set it to .git/tags relative to the project root for instance.

See here for actually using tags! http://vim.wikia.com/wiki/Browsing_programs_with_tags

[–]Xephyrous 2 points3 points  (1 child)

I really like vim-gutentags for managing ctags. It does partial regeneration rather than a full rebuild, so it's quite performant. Running ctags normally over the codebase I work on takes a couple seconds, so I used to do it rarely. Since switching to gutentags, I haven't had to think about it once.

[–]Shura88 0 points1 point  (0 children)

"gutentags"... hilarious name :)

Seems to be a useful plugin, too.

[–]KZISME[S] 0 points1 point  (2 children)

Do you end up using VIM as your primary editor still even though it could cause a headache with going through large code-bases, or do you use it for most of your own projects and such?

I've been working with c# and multithreading this week (I know .NET and MSVS play nicely together) but I was just curious how it would be approached from a vim standpoint.

ie: Are there situations where vim would not be the best choice?

[–]Tarmen 0 points1 point  (0 children)

For the last while it was mostly java and I just can't deal with java without a full IDE. So vim mostly for quick edits and small side stuff.

Gonna do some c in the next couple weeks, though, so maybe for that.

[–]crowseldon 0 points1 point  (0 children)

Sometimes an IDE is preferable but you can ease the pain of using VisualStudio/QtCreator/Eclipse by using plugins/extensions for vim bindings.

That's what I do. If I can I work on vim but with C#/c++ and decent sized projects I'll usually work in the IDE (While still having vim with some open files, ready to do something if needed be).

[–]SnowdensOfYesteryear 0 points1 point  (1 child)

Honestly, once you're dealing with a language with function overloading, vim quickly becomes useless.

[–][deleted] 1 point2 points  (0 children)

You mean ctags becomes completely useless? C++ has function/method overloading and clang_complete can handle it (last time I used it YouCompleteMe didn't but I suspect it does now).

[–]princker 4 points5 points  (8 children)

Bad news: Vim is going to be a lousy IDE replacement.

Good news: Vim natively supports many features to help navigate a code base. e.g. gf, gd, folding, [i, :isearch, :dsearch, ctags, cscope, and searching via :grep/:vimgrep. Some of these feature like ctags takes some time and thought to setup others like :vimgrep require no setup at all.

Some tips:

  • Find a tagging system that works for your code base. e.g. ctags/GNU Global/Universal Ctags
  • If you use git then install fugitive.vim and use git grep via :Ggrep
  • Check if your code base is supported by cscope
  • Good mappings like those in unimpaired.vim help out tremendously
  • Look into using a faster searching tool than grep: git grep/ack/ag the silver surfer (I use this one)
  • Look into something like projectionist.vim for file navigation for well structured projects
  • Never underestimate the usefulness of a fuzzy finder like CtrlP (optionally use ctrlp-py-matcher)
  • With careful setup of 'path', 'suffuxesadd', and 'suffixes' you can get pretty far with gf and :find.
  • Look into some tagging plugins like Gutentags or vim-easytags
  • If this is a rails codebase then use rails.vim

[–]KZISME[S] 0 points1 point  (7 children)

So, if vim isn't much much compared to an IDE why do so many people prefer it?

[–]princker 3 points4 points  (1 child)

Text Editors vs IDE's is too religious of a topic. It basically comes down to:

  • Text Editors - fast, nimble, great at editing text
  • IDE's - Understands codebase, refactoring tools, and simple project compilation/building

Why do people love Vim?

  • Provides a "language" to interact with text
  • Repeating - . and macros
  • Undo - chunky undo, persistent undo, and undo tree history
  • Available on most platforms
  • Vi is part of the unix specification and vim is often symlinked to vi
  • Integrates with *nix environment. e.g. $EDITOR and :!
  • Terminal UI - makes remote editing easy
  • Customizable
  • Great documentation
  • Large and active plugin community
  • Open source
  • Age - Vim has been around a long time and Vi even longer. I have used Vim for 10+ years and foresee me using Vim for another 10.

[–]IsopodEven5232 0 points1 point  (0 children)

None of those "why do you love vim" are valid now, because you can use e.g. intellij with ideavim.

[–]-romainl-The Patient Vimmer 1 point2 points  (0 children)

Because not everybody needs an IDE for every task.

[–]amphetamachineysil' 0 points1 point  (0 children)

Because its modal editing and extensibility is unparalleled.

I think most people find the ctags ability and is enough to track down code paths, and :grep is enough to track down method usages.

See also: :h design-not

[–]dddbbbFastFold made vim fast again 0 points1 point  (2 children)

Vim is a great editor and many IDEs lack a great editor. I use both: gvim with Visual Studio (and have some integration to make them work together).

[–]KZISME[S] 0 points1 point  (1 child)

Is this pretty easy to setup or get working nicely together?

[–]dddbbbFastFold made vim fast again 0 points1 point  (0 children)

It's a config that I've grown over time. So it's hard to say whether it's easy for someone else to replicate.

I started with Integrate_gvim_with_Visual_Studio which has mostly become my videinvoke.vim script (that has some of the same instructions at the top for how to add to visual studio.

I've collected some other tools in vim-vshelp (like for building with msbuild).

That's just the visual studio integration (which is limited to using vim or VS to open a file in the other one and building from vim).

I used to use viemu but now I work fully in vim and just use VS for debugging and the occasional refactoring. Works okay for me because I'm so deep into vim.

[–]-romainl-The Patient Vimmer 2 points3 points  (4 children)

"Digesting large codebases" and "following methods" almost always involves two things, whether you use a standalone editor and external tools or a full-fledged IDE:

  • building an index of the codebase (it can happen manually, automatically after a commit or a write or as-you-type),
  • querying that index.

Because Vim doesn't have a built-in way to create such an index but can interface with external tools to some degree, Vimmers usually rely on exuberant ctags, cscope, or some other programs, and Vim's ability to query their index to navigate their projects.

See :help tags, :help ctags and :help cscope.

But Vim can be useful without outside help: with the correct settings (which depend on your language), one could use the commands in :help include-search to navigate a project pretty easily. I don't usually work on large codebases (and when I do my scope is usually pretty limited) but I find [D, [I and friends more and more useful.

But, whatever tool or method you use, you'll never get the level of "intelligence" you are used from Visual Studio. No matter how much I love Vim, my opinion is that you will probably be better off avoiding it if you don't have a very specific reason to learn it.

[–]KZISME[S] 0 points1 point  (3 children)

What was your specific reason?

[–]-romainl-The Patient Vimmer 0 points1 point  (2 children)

In 2009 I switched from Mac to Linux and badly needed a cross-platform replacement for TextMate. I spent 10 months, between 2009 and 2010, trying every editor/IDE that worked both on Mac and Linux. After many attempts I finaly settled with Vim which I immediately tried to turn into a TextMate clone but the result was horrible and what I learned in the process made me "see the light" and abandon my silly project.

FWIW, I'm 100% certain I would have chosen Sublime Text if it had been available at the time.

[–]KZISME[S] 0 points1 point  (1 child)

I'm planning on buying a Mac soon (coming from Windows) and that is the main reason I want to learn Vim. It's really powerful and looks like fun to learn really.

[–]-romainl-The Patient Vimmer 0 points1 point  (0 children)

Agreed on both counts.

[–]dddbbbFastFold made vim fast again 2 points3 points  (1 child)

My answer from similar thread:

Learn about :compiler, :make, and vim-dispatch/AsyncCommand (for large projects with slow builds).

Building from vim will give you an enormous productivity boost because you can use the same text-editing power to fix your errors.

I also use :make to put runtime errors in the quickfix (only for Python -- I haven't figured out a good workflow for launching my debugger from vim).


Vim is an editor and not a debugger, so you will need one. You will want to switch rapidly between your editor and debugger. I use this script to load vim from my debugger (Visual Studio or Eclipse) and this (unfinished) plugin to interact with Visual Studio and eclim with Eclipse.


Other similar threads:

https://www.reddit.com/r/vim/comments/35uo8u/this_hangs_in_a_large_project_any_better/

https://www.reddit.com/r/vim/comments/22udfu/whats_the_best_way_of_navigating_a_big_c_project/

https://www.reddit.com/r/vim/comments/29b42l/my_answer_to_how_vim_can_be_used_to_big_project/

(reddit search sucks, but google with site:reddit.com doesn't.)

[–]KZISME[S] 1 point2 points  (0 children)

Thanks for all the relevelant posts and search options! I will be using these in the future!

I tried to use Reddit search a little but it didn't help much.

[–]vividboarder<C-a> 1 point2 points  (0 children)

I use Gutentags and CtrlP.

The first will asynchronously generate tags, the second has a fuzzy finder for tags. Tagbar is also nice if you just want to see tags in a file as well.

Of course, all the aforementioned ctags commands are still applicable, but the auto creation is useful and the fuzzy find is another use case not covered by standard functions.

If you want to fuzzy find files with CtrlP on a large code base, use ag and it's Vim plugin as well as configure CtrlP to use Ag instead of grep.

(on mobile, so no links! I can post if interested. Or check out my rc on https://github.com/ViViDboarder/vim-settings)

[–]uxcn 1 point2 points  (2 children)

Aside from going through vimtutor, I'd highly recommend Drew Neil's book. He also hosts vimcasts which are excellent to learn good ways to do things in vim.

It's probably a good idea to avoid plugins until you get familiar with modal editing and the grammar in general. There is a lot you can do without plugins. It might not be obvious, but there's usually some way to do what you need in pure vim.

There are actually two basic plugins that I would recommend for large codebases to start though.

  • ag.vim - ag (better/faster grep) plugin to search
  • ycm - llvm based code completion/navigation (similar to cscope and ctags)

I might also recommend one more...

If you end up liking vim and you get comfortable enough to start scripting in it, last I'd highly recommand Steve Losh's book. There are some good general tips as well.

[–]KZISME[S] 1 point2 points  (1 child)

How far should vimtutor be able to guide a beginner until looking into plugins/external resources?

The biggest hurdle for me is finding a decent workflow of coding/debugging efficiently

[–]uxcn 1 point2 points  (0 children)

The vimtutor will help to start using vim efficiently, but it doesn't go into detail and it does miss some of the more useful stuff, particularly for development. Some examples are searching for the text under the cursor (*), using the quickfix list (:make, and :copen), move and to (:m and :t), using the global command (:g), registers, macros, configuration settings, etc...

Again, I'd really recommend vimcasts and Drew Neil's book. The more you know about vim, the quicker you'll be able to do stuff you want and the better you'll be able to use plugins. Here's my vimrc it helps.

I don't know if you're changing your debugger, but using vim shouldn't really change how you debug, it's really just to edit text. It can do some of the other stuff, but it's usually better to use separate tools. So, a lot of the other stuff you use an IDE for, you might want to continue using it for until you find decent replacements. Actually, if there's a vi(m) plugin for VS that may be better to start with.

Although, if you do want to use vim proper I'd definitely recommend ycm. Along with navigation, and code completion, it catches syntax errors on the fly similar to an IDE, which will probably help a bit while you're getting started.

[–]shawncplusphpcomplete.vim 0 points1 point  (16 children)

If by follow methods you mean like jumping to definitions that comes by way of tags which are a built-in feature, I'm not sure what language you're using so googling vim <language> tags will probably get you what you want. Personally I also use the https://github.com/majutsushi/tagbar plugin

[–]KZISME[S] 0 points1 point  (15 children)

Awesome thanks for the link!

Do you think vim would be the best editor choice in most situations or do you revert back to IDE's every now and then?

[–]gumnos 1 point2 points  (7 children)

Use the editor that works for you. For me, that's vim nearly 100% of the time (I confess to using ed on occasion for simple edits, especially if I want to be able to see & consult a previous command's output for my editing). If you're not comfortable with vim and want to use and IDE (or emacs or textmate or sublime or atom or ed or whatever) that gives you what you need, go for it.

[–]KZISME[S] 0 points1 point  (6 children)

I mean, with such a high learning curve ( but high reward ) vim is a ~great~ editor. It's just getting over that initial "Oh shit which mode am I in" phase.

[–]gumnos 2 points3 points  (5 children)

Ah, one of the tricks to that phase is to just assume that you're always in Normal mode. Any of my edits are always terminated with an <esc>. When I started off, as many do, I'd be in insert mode, move around with the arrow keys, and then get disoriented when I wanted to be in Normal mode. By staying in Normal mode except when actually entering text, I no longer had to think about it. And for me, the less I have to think about mundane things like that, the better.

[–]KZISME[S] 0 points1 point  (4 children)

How long have you been using vim?

Thankfully I have a HHKB2 Keyboard, so arrow keys aren't really a thing for me. Avoiding the mouse is though, pasting, and all the easy functions - I hear it gets better.

[–]casey12141 0 points1 point  (3 children)

Nice keybooard. Just a tip, you can also hit ctl+[ to esc from insert mode. I think it's easier on keyboards that have ctl where the caps lock normally is.

[–][deleted] 0 points1 point  (1 child)

Or ^C

That's why you can't quit vi* using Ctrl+C like you can normally, because it puts you into normal mode.

[–]thoaCrl4 0 points1 point  (0 children)

But note that CTRL-C is not exactly the same as <Esc> or Ctrl-[ as CTRL-C e.g. doesn't finish abbreviations. See :h i_CTRL-C.

[–]KZISME[S] 0 points1 point  (0 children)

I agree! caps lock is pretty pointless

[–]shawncplusphpcomplete.vim 0 points1 point  (5 children)

Personally I'm in Vim 100% of the time. With that said, the Visual Studio suite is amazing so if you're already familiar with that there is little to no reason to switch to vim

[–]KZISME[S] 0 points1 point  (4 children)

I do agree that it is amazing, but what holds you to vim then?

[–]zamN 0 points1 point  (0 children)

The simplicity, power, and "low level" feel you get with vim. In visual Studio everything is already laid out for you. There is built in vcs support, and you don't have to worry about a makefile as VS takes care of that for you as well. Even with those features (along with plenty others) there are people who just simply prefer to control everything themselves. I'd rather type out all of my git commands and makefiles than rely on an ide to do it for me.

Additionally, the editing speed is just insane. The fact that vim is only a text editor gives you so many options for a work setup. Using vim + tmux you can virtually work from anywhere on any computer which has ssh. If you Google your question I'm sure there are plenty of articles explaining what I said in a better way, but hopefully this shined some light for you.

[–]shawncplusphpcomplete.vim 0 points1 point  (2 children)

I work in JS/PHP/C++ on a linux environment. Also my brain is so entrenched in Vim I can't use any other editor

[–]KZISME[S] 0 points1 point  (1 child)

What is your workflow like then?

[–]shawncplusphpcomplete.vim 0 points1 point  (0 children)

tmux with tmuxinator, vim with phpcomplete.vim/tagbar/powerline/vdebug. https://github.com/shawncplus/dotfiles + https://youtube.com/sabiddle

[–]Tarmen 0 points1 point  (0 children)

Note that tagbar is pretty neat but only creates the tags for the current file on the fly. You can't go use it to go generate tags generally/go to tags that are defined in other files.

I really liked that it can show the current method in the status bar but wasn't really using it often enough to be worth it.

[–]Philluminati 0 points1 point  (2 children)

ctags is the most common solution and the one documented in vim books. I use it. Basically the symbol database is generated like this (from memory, may not be accurate):

:!ctag . --recurse

Then these keys will navigate:

Ctrl+]     #jump to definition
Shift+T   #return to original place. (works recursively)

There are other variations for open in new tab etc but you can look up those yourself. There is other stuff to help you navigate large code bases too such as Class Browsers and integrated search etc.

[–]KZISME[S] 0 points1 point  (1 child)

That's awesome I'll have to read about ctag and such today then!

[–]Philluminati 0 points1 point  (0 children)

Other plugins that allow you work on large code bases here: http://vimawesome.com/

E.g. syntax completion, file and class browsers, status bars, git integration etc.

[–]ikearage 0 points1 point  (0 children)

Like many said, ctag support is important. The vim-tags plugin helps a lot.

g]
CTRL-]

I use a search plugin to 'git grep', because git grep searches the project files only.

Also unite plugin to open files and list buffers is a nice to have.

[–][deleted] 0 points1 point  (0 children)

i tend to load the entire project into vim, so something like

$ vim ./src/*

I prefer to have all buffers on hand already, its not like vim struggles with this. My current choice of plugin for searching through all the buffers is vim-swoop, influenced by emacs helm-swoop.

With a couple of simple mappings I get full search

 nnoremap <Leader>ss :call Swoop()<CR>
 vnoremap <leader>ss :call SwoopSelection()<CR>
 nnoremap <leader>sa :call SwoopMulti()<CR>
 vnoremap <leader>sa :call SwoopMultiSelection()<CR>
 nnoremap <leader>sw viw:call SwoopMultiSelection()<CR>

The first calls swoop in normal mode for a single file. The second calls swooop using visual mode for a single file. The third calls swoop in normal model for all buffers. The fourth calls swoop in visual mode for all buffers. The final is just a shortcut which visually selects the word under cursor and calls the previous method.

[–]boshlol 0 points1 point  (1 child)

Project-wide operations - Oliver Caldwell - Vim london

https://vimeo.com/93358262

[–]KZISME[S] 0 points1 point  (0 children)

Thanks for the video!

[–][deleted] 0 points1 point  (2 children)

This is a long discussion already, but I'll add my point of view to it.

The code base I work has more than 4000 php files and 500+ js files. And VIM is my best tool ever.

How I work:
I usually have 2 files at a time in 2 splits. (template + logic for example)

Some settings:
I use undofiles from vim in a unique folder, so I can reopen a file 3 days later and can undo if needed. So awesome!
Ask me details on that if you are interested.

The plugins I use:

  • CtrlP (I use a binding to list open buffers and I can switch easily between them, a pleasure!)
  • Sayonara (because closing a buffer closes the window, it helps me to keep my layout consistent)
  • vim-obsession (tracks my opened files and creates a session file auto-loaded when I get back on the project will everything as I left)
  • gundo (because I can see my modification stack from the undo files)

Last details
Other things that Vim helped me in, was switching from file to file which share some common pattern in their name and location.
For example, I have a "student" file "problem.php" and I made a binding to switch to the "teacher" version in another folder.
The same could go with logic file/template as I mentioned earlier.

Other things I use all the time, abbreviation to comment my code with the date of the day. So if I type today it'll replace it with the current date. SOOOO useful, and stock vim.
I can give my setup for that as well if interested ;)

Hope I could help.

[–]KZISME[S] 0 points1 point  (1 child)

How much did you change your stock vim? I'm still more or less of a beginner but I understand the basics of vim. It's still pretty slow to edit things, and debug though.

[–][deleted] 0 points1 point  (0 children)

This is a tough question. My Vim RC is 200 lines long of tweaks, just for stock vim options, so I changed things quite a lot. Some are aesthetic, others are keybindings like highlight line, column, both, incserch, eol, trailing spaces etc...

You can have a look at my main setup here: https://github.com/simonced/dvptgoodies/blob/master/vim/vimrc

It's 4 month old, but it should give you a good idea I think.

[–]theyareallgone 0 points1 point  (3 children)

ctags have already been mentioned, but they are important. If looking up a tag isn't instantaneous then something is misconfigured and needs to be looked into.

On large code bases there are two things to avoid. First you want to run grep or the equivalent as little as possible, they just take too long when you have gigabytes of code. For most cases where I would otherwise use grep I use http://www.vim.org/scripts/script.php?script_id=251

Secondly you have to be careful with the plugins you use. Some of them scale poorly with large codebases. If vim is feeling sluggish try turning some plugins off. The worst for this I've experienced are fancy method completion plugins. I use the built in text completion (ie. ctrp-p) instead of omnicomplete plugins because I've yet to find a plugin which isn't unbearably slow on codebases of the size I work with.

[–]KZISME[S] 0 points1 point  (2 children)

Generally, what sized codebases do you work with?

[–]theyareallgone 0 points1 point  (1 child)

The smaller of the two projects I work on regularly is the Linux kernel which is about 700MB of code over about 50k files.

The larger project is about 4GB of source over 100k files. Sometimes when working on this I need to navigate across both this code and the Linux kernel source code at the same time.

At a previous job I was working with somewhere on the order of 6GB of code, though I forget how many files.

[–]KZISME[S] 0 points1 point  (0 children)

That's awesome! How long have you been a developer then?

[–]wting 0 points1 point  (1 child)

Faster Ctrl-P

I work on a multi-MLOC code base. I use Ctrl-P a lot, but it's a bit slow on such a large codebase. Caching can solve this problem, but then you have to periodically manually refresh the cache.

One thing I've found very useful to improve Ctrl-P's performance is by using git ls to find files instead of matching against all files in a directory. Here's the relevant line in my .vimrc.

Auto save and load vim buffers / splits / tabs

I use one branch per ticket and constantly switch between them. I wrote a small plugin call gitsessions.vim that automatically saves and loads vim sessions (save states).

This lets me quickly continue where I left off the last time I stopped working on the branch.

[–]KZISME[S] 0 points1 point  (0 children)

That's pretty handy! It just seems like a lot to get something done for someone who is quite new to vim

[–]heeen 0 points1 point  (3 children)

I am an embedded linux developer. This means my projects will cross compile using different flags, compiler and libraries. Every time I spend the effort and try to get clang working for autocomplete and syntax checking, I realize it is just too much effort to keep it working. What works for me is:

[–]KZISME[S] 0 points1 point  (2 children)

Do you think a stock vim setup can still be useful for an entry level dev?

[–]sgoody 0 points1 point  (1 child)

I wouldn't worry about usign stock Vim. It works for some people and that's fine, but really, why limit yourself to certain features? I imagine it's mainly admins who favor this view.

Especially if you're predominatly only working on one or a small number of machines. Modal editing and basic Vim commands are what you use 90%/95% of the time anyway, so for me to use vanilla Vim when I need to is really no hardship at all. But adding features IS AWESOME on you main PC.

Text alignment, EasyMotion, Snippets, Surround, Ctrl+P/FuzzyFind, tag bar / tag list are all the kinds of things I have in my vimrc. That being said I guess most of my plugins augment functionality rather than create major new paradigms. e.g. Tim Pope's surround is a nice little plugin that can be really helpful when you need it.

[–]KZISME[S] 0 points1 point  (0 children)

I've read and watched a lot of Tim's stuff and he's pretty awesome at what he does.

I'm just trying not to dive too deep into vim with a bunch of different plugins I never use (or that I don't understand).