Install Vundle Mac
This page covers how to setup and use YouCompleteMe (Ycm) to enable autocompletion for Gecko/Mozilla-Central development. Setup times will take about ~15 minutes.
Setup (Vim)
I ran into the same problem when I switched to the fish shell on Mac OS X 10.8.1. Thanks go to @pusewicz for providing the solution, which I've expanded upon and added to the wiki FAQ. Copy link Quote reply. Use it if you wish to install through Vundle or Pathgeon. The exVim Full package includes all the plugins pre-installed in exVim. It is a green package, use this if you wish to try or preview exVim and don't want it replace your original Vim. The exVim Windows installer includes the full package of exVim plus GnuWin32 tools used in exVim. Vundle is a plugin manager to make installing things easy. To install Vundle, run the following. Vim 8 is already installed on myth, but if you are installing on your local machine, you may need to upgrade (e.g. Brew install vim on Mac). Here’s my vim config: Plugin 'rust-lang/rust.vim' let g:rustfmtautosave = 1.
- Spf13-vim uses the Vundle plugin management system to have a well organized vim directory (Similar to mac's app folders). Vundle also ensures that the latest versions of your plugins are installed and makes it easy to keep them up to date; install Vundle #vim. GitHub Gist: instantly share code, notes, and snippets.
- Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! Asking for help, clarification,.
- Make sure you're running vim 7.4 or later. On Mac I found it easier to run 'brew install vim' and replace the system vim by creating a symbolic link at /usr/bin/vim OR you can use MacVim. Both should work now. If you using MacPorts you can use something like 'port install vim +python27'
- Install Vundle (the plugin manager that the YouCompleteMe docs recommend, although you can use vim-plug instead):
- Add the following to the start of your .vimrc:
- Consider all adding the following to your .vimrc if you want to use CTRL+]:
- Launch vim and run :PluginInstall
- Build Ycm with the clang option. Follow the quick setup here: https://github.com/Valloric/YouCompleteMe
OSX: If Ycm is having trouble finding system headers, or just in case, run the following:
$ xcode-select --install
- Finally do a full non-artifact build to enable the completions by running
./mach build
. The.ycm_extra_conf.py
script will properly query theobj
directory with the correct include paths and compiler flags.
Setup (Emacs)
- Use the emacs-ycmd package. Follow the setup from the README. It's available from MELPA.
Reporting a Bug
If you encounter any issues please file a bug and make it depend on bug 892973.
Tips
Add your tips here
- Use ':YcmDiag' if the file is showing unexpected error or completion issue(s). This will show the errors that clang is hitting.
- If you don't want to see the preview window after insertion, please try to add 'g:ycm_autoclose_preview_window_after_insertion = 1' into your '~/.vimrc'.
CS 110 is many students’ first experience working with complex projects on thecommand line. In this handout, I’m attempting to aggregate resources that mayhelp you become more efficient. I use Mac OS, iTerm, and vim, and unfortunatelyI don’t know of too many resources for other platforms, but please makesuggestions and I’ll aggregate the tools you all find helpful!
General SSH tips
Avoid SSH timeouts
If you let an SSH session sit too long without activity (sometimes even asshort as a few minutes), you’ll often get connection issues:
This is easy to mitigate by adding the following to ~/.ssh/config
(you mayneed to create this file if it doesn’t exist):
This works on Mac and Linux. It may also apply to Windows, depending on whichterminal emulator you’re using (it should apply if you’re using Ubuntu onWindows).
Avoid having to type your password every time
Add this to your ~/.ssh/config
, replacing yourSunetId
with your Stanford username:
Now, you can simply type ssh myth
. The first time, it’ll ask you for yourpassword, but if you fire up more SSH sessions after that, it log in withoutasking for credentials.
This works on OS X, and I believe it should work on Linux as well. If you’reusing Ubuntu on Windows, you can try it, but I have no idea if it works.
Terminal emulators
iTerm2 (OS X)
iTerm is a replacement for the Terminal.app that ships with all Macs. I highlyrecommend it; it’s loaded with way more features than I know how to use, butalso designed very well such that those features never get in your way. You candownload it and start using it without knowing anything about it in particular.The features I use most often:
- Split panes and split navigation (I am a vim user, and mapped “go left” tocmd+option+H, “go right” to cmd+option+L, etc).
- Quick scrollback reset options
- Better tabbed navigation
- A better search function
- “Instant replay,” to see a history of things printed to the terminal
- A built-in password manager
Vim plugins/tips
If you are new to vim, you can run vimtutor
in your shell to get aminimalistic text-based tutorial on how to use the editor. Even if you knowyour way around, it may be worth skimming through the text; you may findsomething useful you didn’t know existed. OpenVim isa nice interactive tutorial, and, if memory serves me correctly, it’s how I gotstarted with vim. Wikia has a good vimcheat sheet.
There are many more features of vim than I can list here that make itworthwhile to learn; sessions, macros, integrated make
, a huge ecosystem ofplugins, and many other features make it more powerful than many other editorsaround. I’m only listing some tips that I think offer huge time savings, butthere’s a lot more to learn!
Motions
I think one of the biggest reasons people find vim painful is that it takesthem so long to move around a codebase and do the most basic things. There isdefinitely a steep learning curve, but motions in vim are designed such that ifyou learn how to use them well, you’ll be faster than in any other editor.
You should get familiar with basic vim motions (h
is left, j
is down, k
is up, l
is right… You can repeat motions, e.g. 5j
is “move 5 linesdown”). It’s tempting to just use the arrow keys (or your mouse), but if youpractice using these motions, they eventually become second nature, and aremuch faster than the navigation you may be used to.
Other useful motions:
^
is “move to the start of the line,” and$
is “move to the end of the line”b
is “move to the previous word,” andw
is “move to the next word”}
is “move to the next paragraph” (or the next chunk of code), and{
is“move to the previous paragraph”%
means “move to the matching bracket or parentheses” (e.g. if you’re atthe opening bracket of a function and want to move to the end of a function)f
allows you to jump to the next occurrence of a character, andF
allowsyou to jump to the last occurrence of a character. (e.g.f(
will move youto the next open parentheses)
Motions are so useful because they can be combined with verbs. y
is the copyverb; y3j
means “copy the next 3 lines,” and y}
means “copy from here untilthe end of the paragraph.”
Relative line numbers
Relative line numbering is super useful. It makes your line numbers look likethis:
If I want to delete from the current line (line 6) to the line reading set incsearch
, I can look at the relative line numbering to the left, see that thedesired line is 5 lines down, and hit d5j
. This makesdeleting/copying/selecting chunks of text so much easier.
When I switched, I found I didn’t miss absolute line numbering at all. If Ineeded to go to a specific line of a file, I’d just type the number in and hitgg
to jump to that line (e.g. 55gg
to go to line 55).
To enable this behavior, add the following to your ~/.vimrc
:
Enable mouse interaction
I think this is now already enabled in the default .vimrc
for new users atStanford, but I’m not sure. If you add set mouse=a
to your vimrc, you canclick around in the editor, scroll, drag to highlight, etc… In general, it isbetter/faster to use a keyboard to navigate and do things, but sometimes beingable to use a mouse is nice.
Search
Add these lines to your .vimrc:
You can search using the /
character (e.g. type /hello
to find instances of“hello” in your code). Press n
to jump to the next instance of the searchresult and N
to jump to the previous instance.
Split screening
Being able to see multiple files at the same time is super, super useful inthis class!
For easy split navigation, add this to your .vimrc
:
Now, to split the screen horizontally (i.e. to have two panes, one above eachother), in command mode, type :sp
(for “split”). To split the screenvertically (i.e. to have two panes side by side), type :vsp
. To move up(assuming you have the above nnoremaps in your config), press ctrl+k; to movedown, press ctrl+j; to move left, press ctrl+h; and to move right, pressctrl+l.
Once you are in a split pane, you can load a file using :e filename
, or usingFZF (see below).
More on splits:
- http://vimcasts.org/episodes/working-with-windows/ (video)
Marks
Ivms 4500 for mac os x. Sometimes, you’re working on some portion of code, and you want to brieflyglance up at some other part of a file before returning to where you’reworking. You can set a mark where you’re currently working by typing ma
(mark a), then scroll up to wherever you want to go, and then jump back downto where you were before by typing 'a
(go back to mark a). You can setmultiple marks if you want (e.g. mb
will set mark b), but I generally canonly keep track of one in my head…
Vundle
The following tips involve vim plugins.Vundle is a plugin manager to makeinstalling things easy. To install Vundle, run the following:
Then, add the following towards the top of your .vimrc
(if any of thefollowing lines are already in your vimrc, you can omit them):
My tips below mention Plugin
declarations. Add those lines where indicated atthe dashed line above. Every time you add a new plugin to your .vimrc
, savethe .vimrc
file and then run :PluginInstall
to install the new plugin.
Deoplete (autocomplete)
Deoplete provides autocompletesuggestions, making vim behave a bit more like an IDE.
To use it, you will need vim 8 and Python 3.6.1. All the myth machines arerunning vim 8, but if you are doing this on your personal computer, you mayneed to upgrade. (Try brew install vim
on a Mac.) You will also need toinstall pynvim:
Then, you can add the following to your vim config:
If you can’t use vim 8 for whatever reason,YouCompleteMe isanother good autocomplete alternative.
fzf (Fuzzy file finder)
fzf is an excellent plugin for quicklynavigating to files without closing vim. You may see me do this in lecture; Ipress my spacebar twice, enter a few characters that are part of the filename Iwant, then select the desired file, and voila, it’s open!
It has been a long time since I installed this, and I’m forgetting somedetails. Try these instructions and please let me know if you run into problemson myth.
Run this in your shell:
Then add this to your .vimrc
(see Vundle instructions above):
Press “space space” to open fzf. To open a file, hit enter. To split the screenvertically and open the file in the new split pane, press ctrl+v; to splithorizontally, press ctrl+x.
ag (Silver Searcher)
ag lets you quickly find filescontaining a search term. Need to know where the inode
struct is defined?Just type :Ag struct inode {
and you can easily open ino.h
from there.
Again, it has been years since I installed this, and the installationinstructions have since changed, so let me know if you run into problems.
You’ll need to install ag first; on Mac,this is just brew install the_silver_searcher
, but check the linked READMEfor instructions on other platforms. Then, add this to your .vimrc
:
Airline
This is a really great plugin for formatting the vim display. I have it showingmy currently-open files at the top of the screen, and I can press “space 3” toswitch to the 3rd “tab.”
Rust-specific plugins
Install Bundle Mac Download
Rust.vim
Rust.vim provides Rust syntaxhighlighting and formatting, and sets a foundations for some other plugins(such as Syntastic). I would highly recommend installing this. Note that thisplugin requires vim 8 for full functionality. Vim 8 is already installed onmyth, but if you are installing on your local machine, you may need to upgrade(e.g. brew install vim
on Mac).
Here’s my vim config:
This will run rustfmt
on save, so that your code is automatically formattedfor standard style. Free full photoshop download for mac.
Syntastic
Syntastic checks your code forsyntax errors. This plugin requires that you have Rust.vim installed. I have itconfigured so that every time I save, it will highlight any compiler errors,which is pretty handy.
The following is my vim configuration:
Vim Racer
Vim Racer is probably the mostuseful Rust vim plugin in my opinion. It adds “smart” autocomplete options; forexample, if you type SomeStruct.
, it will list the fields inside ofSomeStruct
as autocomplete options. Additionally, it allows you to jump tocode definitions. If you have your cursor on a function, you can type gd
togo to the definition of that function (or gs
to open the definitionin a split pane, gx
to open in a vertical split pane, or gt
to open in anew tab). This even works with library functions, which is quite useful whenyou’re trying to figure out how a function is supposed to be used and you wantto jump to its source code and comments without having to search online.
You’ll need to install racer before youcan use this plugin.
Emacs
Sadly, I know so little about emacs that I’m not sure I even know how to save afile. Please send me recommendations, and I’ll post them here!
- Spacemacs (suggested by Jason C)
For Rust, check out rust-mode.
Sublime Text
Supposedly, Rust support in Sublime is pretty good already, but theRust Enhanced plugin adds someextra features.
IntelliJ
If you’ve never used IntelliJ before, you should check it out; it’s a verypowerful and capable editor, and the professional edition isfree for students!Do note, however, that it is a pretty big memory hog and tends to slaughter myMacbook Air.
Install Bundle Macbook Pro
If you’re using IntelliJ, check out the official Rust plugin.
Install Vundle Vim Mac
Other fun things
Install Bundle Macbook
- zsh is my shell of choice,supporting many nice features over bash. (Honestly, I depend on so many tinyfeatures that I don’t even remember them being unique to zsh anymore.)oh-my-zsh makes it easy to tryit out.
- Mosh is an alternative to SSH that is much more robustover shaky networks and handles intermittent connectivity well. I haven’ttried it myself, but I have heard great things and have wanted to try it fora long time. Please let me know if you give it a spin.