Install Vundle plugin
Install syntax highlighting for rust and other goodies
Add these addons in ~/.vimrc
:
Plugin 'rust-lang/rust.vim'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'ebfe/vim-racer'
Install racer
- Download the source code of version of rust you may be using, say 1.3.0
- Extract the zip file and put in your Development folder ie.
~/rust_src
- Checkout and build racer
mkdir -p ~/rust_src/
cd ~/rust_src/
git clone https://github.com/phildawes/racer
cargo build --release
- Add this to
~/.vimrc
set hidden
let g:racer_cmd = "~/rust_src/racer/target/release/racer"
let $RUST_SRC_PATH="~/rust_src/rust-1.3.0/src"
Install Vim number toggle
vim-numbertoggle shows line numbers to the code you are editing in vim,
You can toggle the numbers to absolute or relative position with respect to your current cursor location.
This will boost your productivity later, when you orchestrate vim commands such as moving 10 lines below the current cursor location 10j
cd ~/.vim/bundle
git clone git://github.com/jeffkreeftmeijer/vim-numbertoggle.git
Install NERDtree for displaying files in a tab
NERDTree is kind of like the left side tabs of most text editors such as sublime
, atom
, or eclipse
where it list down the files in the current directory you are editing from.
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
- Add this to
~/.vimrc
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
"CTRL-t to toggle tree view with CTRL-t
nmap <silent> <C-t> :NERDTreeToggle<CR>
"Set F2 to put the cursor to the nerdtree
nmap <silent> <F2> :NERDTreeFind<CR>
Controls
CTRL-t - Open/Close the files tab
CTRL-n - Toggle relative / absolute numbering
CTRL-ww - Switch between the files tab and the main window
F2 - Focus cursor to files tab
<Enter> - open the focused files/directory, duh!
h,j,k,l - navigate the cursor left, down, up, right respectively
i - insert mode, you can start typing in your code.
<ESC> - back to default mode, where you can issue commands in vi
:w - write/save the file, you are editing
:wqa - save the file, then quit the editor closing vi including the files tab
- You don’t really have to quit
wq
the editor, whenever you want to go back to the shell to build the project.
A convenient way, is to open a new tab in a terminal via<CTRL>
<SHIFT>
t
and issue youcargo build --release
commands from there. That way, you don’t loose state of your editor,
i.e. you can undou
or redo<CTRL>
r
your code changes when needed
Try to vi
ew some files
vi main.rs
- It should look something like this
Enable mouse support
If you want to be able to use the mouse to point and click files, move the cursor around.
- Add this to your
~/.vimrc
"enable mouse support
set mouse=a
Additionally by default, you can use the arrow keys to navigate the cursor.
However, If you are really serious about using vi and want to maximize your vi
skills, you should minimize the use of the arrow keys or the mouse.
A helpful vim cheatsheet at
Automatically reload files when changed
Sometimes some of your files maybe edited outside of your current vi
session, such other editors/code generators, dropbox sync, git pulls.
You may want to have that content be in your current vi
session instead.
- Add this to your
~/.vimrc
" check file change every 4 seconds ('CursorHold') and reload the buffer upon detecting change
set autoread
au CursorHold * checktime
Install in one go for the lazy or those who never have used their vim before
- Make sure you know what you are doing
- This will replace your existing
~/.vimrc
, if you have one - Don’t held me responsible
curl -sSf https://raw.githubusercontent.com/ivanceras/rust-vim-setup/master/setup.sh | sh
Comeback here for changes?
- Update it via
curl -sSf https://raw.githubusercontent.com/ivanceras/rust-vim-setup/master/update.sh | sh
0 comments:
Post a Comment