13

I have been using IDEs like NetBeans for quite sometime. NetBeans has a good versioning control plugin. When I have multiple projects and work on them simutanously, I can choose specific projects to commit by hightlighing them and leave others out. Also the commit box allows me to easily take out unwanted files for commit. I failed to find equivalent plugins for Vim.

I have used Nerdtree; while it is good for project navigating, it doesn't show me which folder/files has been modified. In Netbeans it shows a blue/green icon next to the affected tree path.

There are other features I like in GUI but I am not going to list them all here.

I really want to switch to Vim, but this is stopping me. Could anyone please suggest a similar plugin for Vim?

UPDATE: since this was raised 3 years ago, I have stopped using subversion a while back and started using GIT, the plugins that I am using with vim has Git Support (Fugitive)

James Lin
  • 25,028
  • 36
  • 133
  • 233
  • dont know about vim plugins, but there's a nice vim-like editor plugin for eclipse (vrapper - vrapper.sourceforge.net) – guido Aug 01 '11 at 22:39
  • I don't believe a plugin exists that is nerdtree with highlighting of files that have changed. There are plugins for making it easier to diff 2 revisions inside vim though. Guessing you do not want that though. – giltanis Aug 01 '11 at 22:44

6 Answers6

8

Just use the appropriate shell commands (svn commit, svn update, etc). It wouldn't really make sense to have an SVN plugin for vim. You can even run shell commands from within vim. For example:

:! svn update

Although I'm not sure that that would pose any significant advantage in the case of SVN.

If I want to "cheat" and see the graphical directory structure, sometimes I'll open up Subclipse in Eclipse - but there is absolutely no real need for that.

To get started with vim, just open up a terminal on a machine with vim installed and execute:

vimtutor

You'll be up and running in no time.

mattkelly
  • 626
  • 3
  • 9
  • 1
    That's it, and the right way of thinking, too. @James Lin in the IDE world you have to download a plugin to do anything. In the Vim world, you need to learn the command and/or bind it to a command. – Josh Aug 01 '11 at 22:43
  • Yes, I know within vim can run external commands, but it doesn't help in this case. Say I have 3 projects have code changed, I have a ticket to commit the code against, which is project 1 & 3, to commit the code changes together in one revision, I will have to run svn commit on the root folder, which includes project 2 changes, now how do I easily take out the files in project 2 in the commit list? – James Lin Aug 01 '11 at 22:48
  • It's been a while since I've used svn (migrated to git), but you may have to run two commit commands - one for each directory. Else there may be a way to commit two directories with one command. There is no need to commit the root directory and explicitly exclude one of the subdirectories (unless of course this somehow ends up being easier). – mattkelly Aug 01 '11 at 22:54
  • @mattkelly, if I run 2 commit commands then it will result in 2 revisions. – James Lin Aug 01 '11 at 23:00
  • 1
    @James You're right, I forgot about that. However it does look like you can just list the directories you wish to commit. See this thread: http://stackoverflow.com/questions/1516188/svn-commit-specific-files – mattkelly Aug 01 '11 at 23:08
  • @mattkelly yeah, I know I can do that, but it's unnecessary to list 20 files just to exclude 1. – James Lin Aug 01 '11 at 23:11
  • 2
    if you have your two projects in different directories couldn't you just commit those two directories and not the one you are excluding? as in $svn commit -m "commit project1 and project3 but not project2" ./project1 ./project3 – digitaljoel Aug 01 '11 at 23:19
  • @digitaljoel, yes, that would work thanks. Now, second problem, within the same project, eg. I have 30 files to commit, how do I just exclude 1? – James Lin Aug 01 '11 at 23:29
  • 2
    @James Lin: something like `$svn commit -m "test" $(ls | grep -v anything_but_this_file)` – bhinesley Aug 02 '11 at 05:00
  • @mattkelly i'd agree except where excellent plugins like Bob Hiestand's vcscommand provide excellent additions to what can be done using the shell. I'm specifically thinking of comparing different versions of the same file using the inbuilt vimdiff facility. Saved my bacon many a time! – Rob Wells Aug 29 '16 at 14:47
5

There are a few vim plugins for subversion, although it's true that none of them give you the full IDE-like integration that you'd like. A lot more can be done with git since it's inherently more flexible, and, if you're curious, fugutive is a very nice plugin for that: http://vimcasts.org/blog/2011/05/the-fugitive-series/

But, to the point. Here are a few plugins that might help with your specific request and a few more in general:

  • Sandbox: http://www.vim.org/scripts/script.php?script_id=2468. It doesn't quite do what you asked for, but you could use it for the same purpose. Whenever you want to see the status of the repo and selectively commit files, you could execute the Sandbox command and follow the instructions. The script does say "Linux only", though. You didn't mention what OS you're using, so if you're on Windows, I don't know if it'll work properly.
  • VCSCommand: http://www.vim.org/scripts/script.php?script_id=90. This one gives you diffs, logs on a specific file, blame, revert and a few other things. The interface consists of commands or mappings.
  • svn_commit: http://www.vim.org/scripts/script.php?script_id=1451. A very small script that "remembers" the last commit message, so if you cancel committing to add/remove files, you don't have to type it again.

Again, you're probably not going to get the integration you'd like. Vim is very flexible, but some IDE features are difficult to get working in it. I can see a possible solution, but it'd require a while to write and test properly. I'm sorry about it, but you're going to have to either adapt to using the command-line client, like @mattkelly suggests, or consider using an external program to deal with committing, following the advice of @romainl.

Andrew Radev
  • 3,982
  • 22
  • 35
4

I recommend VCSCommand. It has convenient mappings out of the box, and it works with svn, git and hg. However, it doesn't really have a "GUI" per se; I don't think you will find many vim-oriented resources that do.

Max Cantor
  • 8,229
  • 7
  • 45
  • 59
2

First off, I totally support @matkelly's answer: You don't need any plugin for using SVN from within VIM.

As an avid vim user I would like to give some pointers on using vim as an IDE along with subversion integration.I have few snapshots I just took of my vim screen so you have a visual.

I come from an eclipse background. Though now I mostly code on VIM on my Fedora workstation. I still use eclipse for certain tasks which its good at, such as Mylyn/Tasktop integration (through Planning Perspective) which integrates with subversion and bugzilla to help me write task-specific commit messages.

In VIM, to interact with SVN painlessly (and general shell tasks for that matter) you need to know few shortcuts:

I get the logs for the file I'm currently working on with:

:!svn log -l3 %

'%' is a special shortcut which gets replaced with the current file path.Above command lists the last 3 log message for this current file.

Guess what this command does?

:!svn diff %

'%:h' gives you the directory currently file is in:

:!svn status %:h

While I'm on the subject, here are few pointers for new vim users who want to make a switch from a GUI-IDE to vim and have hard time navigating through thousands of project files:

I recommend the NERDTree plugin, which opens up an IDE-like directory tree and locates your current file in the tree. It's only useful to me in rare occasions (to delete, copy, move files or to set my current working directory). But if all I want were to locate a specific file from among hundreds of files in my project, I just type:

:find Inventory.pm

Cool thing is, I can type filename partially and hit [TAB], which expands the file name for me!!! If there are several matches it simply iterates through the list until I find the one I meant.

This is the first command my coding session starts with; I CD to my project root folder (since vim's 'path' setting is set to '.'), fire up VIM and type :find Filename. No GUI IDE that I've used could pull this off this fast. Then, if I wanted to browse my project folder, I just hit F10, which maps to NERDTreeFind, and use jklm VIM commands to navigate the directory structure.

When I have several buffers (files) open in VIM, to navigate open buffers easily I use "Buffer Explorer".

When I'm typing a method or some keyword in VIM i type "CTRL-N", which opens up tag list (I have exuberant ctags setup through cron).

"Tag List" plugin is also a must, which opens up list of functions/methods in the current buffer, locates the method you're currently on, and focuses on it.

VIM Screenshot1

VIM Screenshot2

Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
sherzodr
  • 101
  • 1
  • 4
1

You can have a try the plugin from GitHub, https://github.com/juneedahamed/svnj.vim

Tmx
  • 579
  • 2
  • 6
  • 17
0

For simple tasks, you should follow mattkelly's advice:

:!svn co path/to/repo .
:!svn add .
:!svn commit -m 'first commit'
:!svn update

However it may make more sense to leave file manipulation to tools specifically designed for that.

There are SVN file explorer plugins available for Windows, Mac OS X and Linux. They are powerful enough to handle most situations with ease.

If you have to deal with really complex situations, did you consider dedicated graphical tools like RapidSVN or SmartSVN or others?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
romainl
  • 186,200
  • 21
  • 280
  • 313