Related
I installed Latex-Suite for Vim, and I like it very much, but I'd like to be able to customize the environment mappings that came by default, and add new ones. For example I want to edit the equation environment that appears typing EEQ and move around some elements, like the \label{} command. How can I do this? I've been scanning everything inside my /usr/share/vim/vimfiles/ftplugin but I can't find a way to do it (or I just don't understand what those files are).
You want to check out the documentation on Macro Customisation, specifically the Tex_Env_{name} bit.
In short, if you want your theorem snippet to look like
\begin{theorem}
<++>
\end{theorem}<++>
then you want a line like
let g:Tex_Env_theorem = "\\begin{theorem}\<CR><++>\<CR>\\end{theorem}"
in your vimrc.
Note the backslashes to escape carriage-return, and double-backslash for normal backslashes.
The <F5> functionality (press F5 after typing an environment name, i.e. figure<F5>) should work out of the box, but you may need to refresh the three-letter code. This is more hassle than it needs to be, but something like
autocmd BufNewFile,BufRead *.tex call IMAP('EFI', g:Tex_Env_figure,'tex')
will do the job.
The answer to the question you asked comes with a caveat, which is that Latex-Suite is an enormous amount of code that is very hard and annoying to modify, and which does not play nicely with other plugins. This falls into Latex-Suite's philosophy that it's the only plugin you need for editing latex within vim.
That said, you want to look in /path/to/ftplugin/latex-suite/envmacros.vim. Searching for EEQ will lead you on the path to understanding the set of calls that latex-suite performs. I would like to reiterate that many functions are deeply intertwined.
On the other hand, there is a very easy way to have very easily customizable environments, which are snippets. See the UltiSnips page for a good example of how this works. These are designed for customization and extremely easy to write.
Looking for a linux text editor. I can fumble my way through emacs a little but only really know the basics. I liked TextMate on OSX but thought it was a bit weak at times (maybe I just didn't learn it well enough). I don't know if emacs or vim are worth it since I'll still mostly program in eclipse.
Syntax highlighting
Themeing support. I'd like something like sunburst if possible.
Hopefully don't have to think in a different way when I use it versus other programs. i.e. I don't think I want to learn all the shortcuts for emacs/vi. (If I were to be sold on this route I'd need something to help me get up to speed quickly and hopefully something in app that helps discover functionality as I go). Cream might be a go here but I don't know what I'm missing if I do that.
Mouse usage (text selection, cursor placement, etc)
doesn't look awful (yes aesthetics do matter to me).
Auto-formatting support
Light-weight
Easily callable from the command line.
Depends on the task at hand.
I've been using Geany to write scripts, it has basic IDE functions, good syntax highlighting etc.
+1 for vim. The learning curve can be a bit steep, but vimtutor can help you a lot.
Once you get accustomed to it you'll wonder how you lived without it.
gEdit. Has a bunch of plugins and has support for vi bindings. I think it meets all of your requirements.
+1 for Vim - it's my all time favorite editor and the more I learn about the shortcuts and use more plugins and stuff, I would never go to another editor :) Although in my spare time I have started dabbling with Emacs, just for the kicks. Vim essentially has two modes - normal and insert, so you switch back and forth between them. In the insert mode you type, in the normal mode you do magic with the shortcuts. The power is awesome and after a while it becomes intuitive, and you start finding that you just did a keyboard combination and it worked as you expected, although you never specifically read about this combination. E.g. delete till the character 'x' before the current position of the cursor = Esc+d+T+x (when you only knew that Esc+d+t+x (small t) works in the forward mode.
Simpler ones on Linux are nano, pico, and gEdit :)
I recommend Komodo Edit for big projects. It's possible to create macros, key-bindings for commands and snippets through an easy-to-use interface. And there's a good syntax highlight support for most languages too.
A second choice would be geany. It's faster and simple, useful for the most cases where you just want to edit a single file or a small project.
If you wish to learn vim or emacs, then print yourself the vim or emacs quick reference card.
In fact, I'd recommend learning vim or emacs even if you wind up mostly using a more modern editor simply because they exist when nothing else does.
I personally prefer vim because many vim commands match sed and perl commands, definitely consider vim if you use these often. And you should obviously pick emacs if you like lisp.
There was an issue with bash's vi mode in which it ignored the arrow keys for ages, which forced people into using vim for editing and emacs mode in bash, but now set -o vi works correctly in bash.
I have started to do some programming using VIM.
I have very mixed feelings so far. On one side I do love the idea, on the other - it is just hard to remember everything.
So I took the approach of learning while actually doing some stuff (for Ruby on rails development).
Unfortunately there is no chance in hell for me to be more productive as in other "conventional" text editor for now. And it seems it will take quite a lot of time to get used to VIM.
I noticed, that I often don't use VIM navigation/search&replace abilities, but instead just move around as I would do in other editors.
I am trying hard pushing myself not to open anything in other editors except VIM so I can learn it.
But, honestly, yesterday I gave up and did my last 20 minutes of coding in GEdit.
UPDATE: I want to say why I gave - just because of I would finish what I need faster (it was veeeery late and it was not the best time for learning VIM). And indeed I did enjoy using VIM. But I always had the "there must a better way of doing this" feeling and spent a lot of time finding that way.
So my question wold be: how can I learn and start using VIM more productively from day to day provided that I want to do some real coding when learning?
Thanks,
Dmitriy.
Keep the following in mind. While there are physical limits to the speed of your fingers, there seem to be few limits on the processing that your brain can perform. Therefore, the time you invest in learning vi(m)'s keyboard editing commands and shortcuts will be paid back handsomely over time as the speed with which you edit improves breaking the physical speed limits you would encounter when using a traditional editor. For instance, to delete the next five words in vi(m) you type 5dw and to insert 50 * characters you type 50i* ESC.
You can begin using vi(m) after learning very few commands: basic movement, inserting, changing, deleting, opening a new line, and saving a document. Coupling these commands together produces powerful combinations. As you master these, you'll be looking for more.
Print a vi reference sheet (like this, or this or this more extensive list), and keep it near you at all times.
I use Gvim (the GUI mode). If you forgot the key sequence for some action you can invoke it through the GUI. For most actions you can also see the necessary keys, so that Gvim can also serve as a quick reference for Vim.
Off course a different text editor will not magically make you more productive. But if you like to use keyboard shortcuts on the mainstream editors, you'll like Vim because you can trigger fairly powerful actions with a few keystrokes.
I personally don't like Vim, I prefer mainstream editors. But Vim has REST syntax coloring, and I found it perfectly usable after about a week.
Why? Use whatever editor suits you best and makes you the most productive. I use vi for editing configuration files, because it's usually the quickest way to edit a few lines and then exit. For serious programming, it's either TextMate (ruby), Emacs (python or ruby on platforms without TextMate) or Xcode (objective-c).
Start using it when it makes sense : quick edits on config files, commit messages, README updates, etc...
The startup speed can difficult be beat.
When you get the hang of the basics, explore the help file if you think "there must be something in there for the task I need to do now". ...
Build the knowledge gradually.... step by step...
Until you find one day you do a lot of your editing in VIM or find that your toolchain is well integrated with Vim.
I personally use whichever works best, IntelliJ for Java, Emacs for clojure, Vim for perl and ruby scripts, ...
I'm more static typed languages guy and here is my story:
For me VIM was all about hjkl movement in normal mode + intert mode. I've found it so efficient that I wanted to have it all the time, everywhere.
Then I started to read cheatsheets from time to time and picking up the best gestures to remember (somehow sorted from most commonly useful to less useful ones): b, w, x, gj, gk, gg, G, numberg, *, #, %, f/t/F/T, /, >>, <<, =, v then mark with j/k, <</=/>>.
Then I started to write Makefiles to everything and configured Vim to impretet it. So I do :mak and I'm right at the line that error was found.
Then autocompletion happened (binded to TAB).
Then natural language checking z=.
Then I've written a wrappers for switching buffers. Opening them with :e filename.c and then doing Ctrl+l, Ctrl+h.
I have my config publicly available in git archive here:
http://github.com/dpc/vim-config
I am trying hard pushing myself not to open anything in other editors except VIM so I can learn it.
But, honestly, yesterday I gave up and did my last 20 minutes of coding in GEdit.
Developer should be comfortable with the environment he works with. That's why there are lots of editors developed by the developers for the developers.
As long as the editor does what you want, the way you want, it is all fine: editor is just a mean to do the work.
So my question wold be: how can I learn and start using VIM more productively from day to day provided that I want to do some real coding when learning?
For the VIM, unfortunately, my recommendation would be to spend several days with it without doing any real work, but simply learning. It took me about two days to get to know the basic functions required for the efficient editing. I knew that editor would play important role in my daily work that's why I have invested close to the week of my spare time to learn both VIM and Emacs.
My ex-colleague also kept a VIM cheat sheet as his desktop wallpaper. Helped in the beginning.
This might help: Why, oh WHY, do those #?#! nutheads use vi?
Anyone else looking to learn Vim should check out the Open Vim website. It is a fantastic resource for any newcomer to Vim. It has an interactive tutorial and various sandbox modes for playing with the editor. Have fun!
I've heard very good things about SwaroopCH's Byte Of Vim book. Haven't gotten around to reading it myself yet, but his Byte Of Python book is definitely excellent.
Learn at your rhythm. I think you should start mastering the basics:
modes: command, normal and visual
the commands: paste, yank, delete.
Then you can improve these knowledges:
learn some useful commands in command mode (list buffers, substitution)
learn to move faster (beginning/end of the word/line/file)
search/substitute a pattern
Look at people's vim config and customize yours
While doing this, always keep a vim cheat sheet near you. The basics commands are easy to remember (d for delete, p for paste, y for yank, i for insert, a for append, ...).
Learn progressively and stay simple.
How about books?
These ones are excellent:
Learning the vi and Vim Editors
VI Editor Pocket Reference
And after all, so what - so you don't work with vim. What is the big added value for vim, which worth the difficulty of learning it?
Here's some novel advice from Yehuda Katz, a core member of the Ruby on Rails team who recently switched to Vim: Try using it exactly the same as you would any other editor at first so you can keep being productive. Maybe this means continuing to use the arrow keys or *gasp* mouse at first. Don't try to learn all the Vim ways at once. Rather, let them come slowly and naturally.
The full article is a great read:
Everyone Who Tried to Convince Me to use Vim was Wrong
Additionally, try using vi key bindings in other applications. If your shell supports vi movement, use that. For web browsing, try the phenomenal Vimperator Firefox plugin.
Perhaps some Easter Eggs would help you get started on the right foot. Try the following and enjoy the wonderful world of open source tradition and legacy of contained silliness :)
:help 42
:help holy-grail
:help!
:help map-modes (see comment below the table about :nunmap)
:help UserGettingBored
:help spoon
:help showmatch (read the note)
:Ni!
(know more: visit vim.org)
vim takes a lot of time to get used to and actually be productive with
this is how i look at it:
suppose your productivity index is anywhere between 1 and 10
when you start using an other editor, your productivity index is like 6, and can go up to 8.
when you start using vim, your productivity is like 2, but you can go up to as high as 10. it just takes time.
Here is how I learnt when I switched from Windows to Linux:
1) I printed out the vim quick reference card(pdf) and kept it next to my keyboard at all times.
2) I started off with gvim and used the easy mode (gvim -y or evim). This makes vim behave like a regular editor - it is always in insert mode, and the keys are mapped to work like a regular CUA editor (e.g. CTRL-X/C/V for cut/copy/paste). You can still access all the vim functionality with CTRL-o to enter a single Vim command, then it will go back to insert mode.
After a while I got fed up with using CTRL-o or the menus all the time, and switched to proper Vim mode. I have not looked back since then and now use Vim for everything, even on Windows. I even use Vimperator on FireFox.
It is also worth taking a look at Cream - this is like vim easy mode on steroids.
If you find that you comfortable using evim or cream then there is no reason that you have to go all the way switch to normal vim mode, whatever vim purists may say. You should aim to become a master of your tools, not a slave to them.
There are important features of Emacs which are missing in Vim, such as the comint mode, and there are no scripts/plugins which can replace them.
There are also benefits of Vim over Emacs, such as modal editing and generally better default shortcuts. However, Viper mode gets me both. Vimpulse also enables visual mode.
Unfortunately, no mode can make Emacs work as fast as Vim.
So I mostly learned Vim-in-Emacs. What Vim features am I missing?
I'm a regular vim user but not an emacs user and haven't used vimpulse to confirm this.
But browsing the vimpulse code below I see no mention of text objects.
http://www.emacswiki.org/cgi-bin/wiki/vimpulse.el
Vim introduced some very useful idioms for selection and movement that aren't in regular vi
cat 'cut around tag' for xml/html tags
diw 'delete in word'
di( di" delete text within a "" () etc.
in the vim help see :he text-objects for more.
Unfortunately, no mode can make Emacs work as fast as Vim.
If you mean that the emacs startup time is poor, you can cut it down dramatically by having an emacs session permanently open, and use gnuclient/emacsclient whenever you need to edit a file.
http://www.emacswiki.org/emacs/GnuClient
One vi feature that I miss in emacs is the . (dot) command that repeats the last edit. There is dot-mode.el which implements C-. to simulate this but it didn't always work for me (I am not proficient in elisp to figure out why).
Even viper doesn't implement this command exactly like vi does (last time I checked), and even if it does, I don't think that is enough for me to start using viper.
To get a complete list of what vimpulse may be missing type
:helpgrep not in Vi
Every feature in the help that is not vi compatible will be listed.
Theres about 700 matches.
Of course there will be a lot of duplicated functionality
Vi motion everywhere - in Vi you can always navigate using the same shortcuts, whether you are inside a directory listing, a help file, a write only file or something you're allowed to edit.
Correct visual and delete behaviour - very similar to emacs marking but idiomatically different, so difficult for a Vi user to retrain. If you're already used to the emacs marking you're not really missing anything.
Correct escape behaviour - should cancel all other modal activity and return you to command mode. Again, if you're comfortable in emacs you're probably used to having modal inputs and such anyway.
The obvious chestnuts about Vi being deployed on every nix system in the world (Gentoo purists correct me?) - not a very strong argument in my eyes anyway.
Those are the ones that sprang out during my use of emacs+viper.
Vim macros don't seem to work with viper/vimpulse:
Vim macros don't work when using viper + vimpulse in Emacs
(Btw, the killer emacs feature that makes me care about vim/vimpulse is that different frames can edit the same file. It's like having a split where the two pieces can be in different windows. If anyone knows how to accomplish that in vim, you'd be my hero.)
Incremental search using / and ? is missing.
Being a lover of emacs as an OS and vi as an input model, naturally I wanted to love viper. However within two seconds of using it I had to give it up: viper does not support C-[ as a substitute for the escape key–which is an essential shortcut for the most frequently used command in vi.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
What are your favorite (G)Vim plugins/scripts?
Nerdtree
The NERD tree allows you to explore your filesystem and to open files and
directories. It presents the filesystem to you in the form of a tree which you
manipulate with the keyboard and/or mouse. It also allows you to perform
simple filesystem operations.
The tree can be toggled easily with :NERDTreeToggle which can be mapped to a more suitable key. The keyboard shortcuts in the NERD tree are also easy and intuitive.
Edit: Added synopsis
Tim Pope has some kickass plugins. I love his surround plugin.
Pathogen plugin and more things commented by Steve Losh
Taglist, a source code browser plugin for Vim, is currently the top rated plugin at the Vim website and is my favorite plugin.
I love snipMate. It's simular to snippetsEmu, but has a much better syntax to read (like Textmate).
A very nice grep replacement for GVim is Ack. A search plugin written in Perl that beats Vim's internal grep implementation and externally invoked greps, too. It also by default skips any CVS directories in the project directory, e.g. '.svn'. This blog shows a way to integrate Ack with vim.
A.vim is a great little plugin. It allows you to quickly switch between header and source files with a single command. The default is :A, but I remapped it to F2 reduce keystrokes.
I really like the SuperTab plugin, it allows you to use the tab key to do all your insert completions.
I have recently started using a plugin that highlights differences in your buffer from a previous version in your RCS system (Subversion, git, whatever). You just need to press a key to toggle the diff display on/off. You can find it here: http://github.com/ghewgill/vim-scmdiff. Patches welcome!
Elegant (mini) buffer explorer - This is the multiple file/buffer manager I use. Takes very little screen space. It looks just like most IDEs where you have a top tab-bar with the files you've opened. I've tested some other similar plugins before, and this is my pick.
TagList - Small file explorer, without the "extra" stuff the other file explorers have. Just lets you browse directories and open files with the "enter" key. Note that this has already been noted by previous commenters to your questions.
SuperTab - Already noted by WMR in this post, looks very promising. It's an auto-completion replacement key for Ctrl-P.
Desert256 color Scheme - Readable, dark one.
Moria color scheme - Another good, dark one. Note that it's gVim only.
Enahcned Python syntax - If you're using Python, this is an enhanced syntax version. Works better than the original. I'm not sure, but this might be already included in the newest version. Nonetheless, it's worth adding to your syntax folder if you need it.
Enhanced JavaScript syntax - Same like the above.
EDIT: Comments - Great little plugin to [un]comment chunks of text. Language recognition included ("#", "/", "/* .. */", etc.) .
Not a plugin, but I advise any Mac user to switch to the MacVim distribution which is vastly superior to the official port.
As for plugins, I used VIM-LaTeX for my thesis and was very satisfied with the usability boost. I also like the Taglist plugin which makes use of the ctags library.
clang complete - the best c++ code completion I have seen so far. By using an actual compiler (that would be clang) the plugin is able to complete complex expressions including STL and smart pointers.
No one said matchit yet ? Makes HTML / XML soup much nicer
http://www.vim.org/scripts/script.php?script_id=39
Tomas Restrepo posted on some great Vim scripts/plugins. He has also pointed out some nice color themes on his blog, too. Check out his Vim category.
With version 7.3, undo branches was added to vim. A very powerful feature, but hard to use, until Steve Losh made Gundo which makes this feature possible to use with a ascii
representation of the tree and a diff of the change. A must for using undo branches.
Matrix Mode.
My latest favourite is Command-T. Granted, to install it you need to have Ruby support and you'll need to compile a C extension for Vim. But oy-yoy-yoy does this plugin make a difference in opening files in Vim!
Conque Shell : Run interactive commands inside a Vim buffer
Conque is a Vim plugin which allows you to run interactive programs, such as bash on linux or powershell.exe on Windows, inside a Vim buffer. In other words it is a terminal emulator which uses a Vim buffer to display the program output.
http://code.google.com/p/conque/
http://www.vim.org/scripts/script.php?script_id=2771
The vcscommand plugin provides global ex commands for manipulating version-controlled source files and it supports CVS,SVN and some other repositories.
You can do almost all repository related tasks from with in vim:
* Taking the diff of current buffer with repository copy
* Adding new files
* Reverting the current buffer to the repository copy by nullifying the local changes....
Just gonna name a few I didn't see here, but which I still find extremely helpful:
Gist plugin - Github Gists (Kind
of Githubs answer to Pastebin,
integrated with Git for awesomeness!)
Mustang color scheme (Can't link directly due to low reputation, Google it!) - Dark, and beautiful color scheme. Looks really good in the terminal, and even better in gVim! (Due to 256 color support)
One Plugin that is missing in the answers is NERDCommenter, which let's you do almost anything with comments. For example {add, toggle, remove} comments. And more. See this blog entry for some examples.
I like taglist and fuzzyfinder, those are very cool plugin
TaskList
This script is based on the eclipse Task List. It will search the file for FIXME, TODO, and XXX (or a custom list) and put them in a handy list for you to browse which at the same time will update the location in the document so you can see exactly where the tag is located. Something like an interactive 'cw'
I really love the snippetsEmu Plugin. It emulates some of the behaviour of Snippets from the OS X editor TextMate, in particular the variable bouncing and replacement behaviour.
Zenburn color scheme and good fonts - [Droid Sans Mono](http://en.wikipedia.org/wiki/Droid_(font)) on Linux, Consolas on Windows.
If you're on a Mac, you got to use peepopen, fuzzyfinder on steroids.
I use the following two plugins all the time:
project
vimoutliner
For vim I like a little help with completions. Vim has tons of completion modes, but really, I just want vim to complete anything it can, whenver it can.
I hate typing ending quotes, but fortunately this plugin obviates the need for such misery.
Those two are my heavy hitters.
This one may step up to roam my code like an unquiet shade, but I've yet to try it.
Txtfmt (The Vim Highlighter)
Screenshots
The Txtfmt plugin gives you a sort of "rich text" highlighting capability, similar to what is provided by RTF editors and word processors. You can use it to add colors (foreground and background) and formatting attributes (all combinations of bold, underline, italic, etc...) to your plain text documents in Vim.
The advantage of this plugin over something like Latex is that with Txtfmt, your highlighting changes are visible "in real time", and as with a word processor, the highlighting is WYSIWYG. Txtfmt embeds special tokens directly in the file to accomplish the highlighting, so the highlighting is unaffected when you move the file around, even from one computer to another. The special tokens are hidden by the syntax; each appears as a single space. For those who have applied Vince Negri's conceal/ownsyntax patch, the tokens can even be made "zero-width".
tcomment
"I map the "Command + /" keys so i can just comment stuff out while in insert mode
imap :i