Difference between revisions of "VIM"
From Vlsiwiki
(→C/C++) |
(→Shortcuts) |
||
(17 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
=Latex= | =Latex= | ||
+ | |||
+ | === Shortcuts === | ||
+ | |||
+ | === Configuration === | ||
=Verilog= | =Verilog= | ||
+ | |||
+ | === Shortcuts === | ||
+ | |||
+ | === Configuration === | ||
=C/C++= | =C/C++= | ||
− | + | VIM can call your make command directly and point to the next compilation error. This works even with remote compile. | |
− | == Configuration == | + | === Shortcuts === |
+ | |||
+ | ==== Compile ==== | ||
+ | |||
+ | Once you compile your program ":make", you can move across the errors | ||
+ | |||
+ | Go to the current error (first one if you just run make). This will print the gcc error | ||
+ | |||
+ | :cc | ||
+ | |||
+ | You can go to the next error | ||
+ | |||
+ | :cn | ||
+ | |||
+ | Or the previous one | ||
+ | |||
+ | :cp | ||
+ | |||
+ | ==== Align Code ==== | ||
+ | |||
+ | If you use the align package, just try to align the assignments. Select the whole line (V), and align the code to the = sign. | ||
+ | |||
+ | V | ||
+ | \t= | ||
+ | |||
+ | === Configuration === | ||
+ | |||
+ | By default ":make" runs the make command in the current directory (:pwd). You can change as follows | ||
+ | |||
+ | set makeprg=gmake\ -C\ ~/build/qemu | ||
+ | |||
+ | In fact, you can even set a remote compilation in another machine. | ||
+ | |||
+ | set makeprg=ssh\ mada7\ \"gmake\ -C\ ~/build/qemu\" | ||
=Editing= | =Editing= | ||
− | == Shortcuts == | + | === Shortcuts === |
* :''x'' - Jump to line 'x' in the file | * :''x'' - Jump to line 'x' in the file | ||
− | * y'' | + | * y''x''y or ''x''yy - Copy x lines to clipboard |
+ | * d''x''d or ''x''dd - Cut x lines to clipboard | ||
+ | * SHIFT% - Finds a pair. For example, you want to find a match to the currently highlighted bracket. | ||
+ | * SHIFT# - Searches for a word | ||
+ | * gg - Takes you to the top of the page. | ||
+ | * SHIFTg - Takes you to the bottom of the page. | ||
− | |||
− | * set nocompatible " Disables troublesome VI compatibilty | + | |
− | + | * Substitution | |
− | + | :%s/'x'/'y'/gc - Replace 'x' with 'y' on all lines (%) | |
− | + | :15,25s/hello/goodbye/g - Replace 'x' with 'y' from between lines 15 and 25 inclusive | |
− | + | :78s/hello/goodbye/g - Replace 'x' with 'y' only on line 78 | |
− | + | ||
− | + | Options for substitution | |
+ | g Global -- Change every occurrence on a line, not just the first | ||
+ | c Confirm -- Ask before making each change | ||
+ | |||
+ | === Configuration === | ||
+ | |||
+ | Configuration file to have efficient editing. | ||
+ | |||
+ | set nocompatible " Disables troublesome VI compatibilty | ||
+ | set title " Sets the title bar to give the filename and path | ||
+ | set ruler " Enables the location information in bottom right corner | ||
+ | set nowrap " Disables text wrapping | ||
+ | set ignorecase " Searches ignore case | ||
+ | set wildmenu " Menu for autocomplete of filenames | ||
+ | set number " Prints line numbers on left of screen | ||
=Color Scheme= | =Color Scheme= | ||
+ | |||
+ | === Shortcuts === | ||
+ | |||
+ | * Change the current colorscheme | ||
+ | |||
+ | :colorscheme ''schemename'' | ||
+ | |||
+ | === Configuration === | ||
+ | |||
+ | * This is a color scheme which I created for myself, but feel free to use it; works best on black backgrounds. [http://users.soe.ucsc.edu/~IanLee1521/files/ian.vim ian.vim] -- [http://users.soe.ucsc.edu/~IanLee1521/files/vim_colorscheme_ian.png Screenshot] -- To install, place the file in your ~/.vim/colors/ directory, (~/.vim/colors/ian.vim), and add the following line to your .vimrc or .gvimrc file | ||
+ | |||
+ | colorscheme ian | ||
+ | |||
+ | * It is possible to set any file to highlight the syntax correctly for any filetype needed, by associating the filetype with a vim syntax file. | ||
+ | |||
+ | * For Ruby Verilog, add the following line to your ~/.vimrc file. This will enable Verilog syntax highlighting in Ruby Verilog files. | ||
+ | |||
+ | au BufNewFile,BufRead *.rv set ft=verilog | ||
+ | |||
+ | * For CUDA Files, you need to do one extra step. You will need to save this [http://users.soe.ucsc.edu/~IanLee1521/files/cu.vim CUDA syntax file] to your ~/.vim/syntax/ directory, and then add the following two lines to the ~/.vimrc file. | ||
+ | |||
+ | au BufNewFile,BufRead *.cu set ft=cu | ||
+ | au BufNewFile,BufRead *.cuh set ft=cu |
Latest revision as of 17:06, 18 May 2010
Under Construction!
Contents
Latex
Shortcuts
Configuration
Verilog
Shortcuts
Configuration
C/C++
VIM can call your make command directly and point to the next compilation error. This works even with remote compile.
Shortcuts
Compile
Once you compile your program ":make", you can move across the errors
Go to the current error (first one if you just run make). This will print the gcc error
:cc
You can go to the next error
:cn
Or the previous one
:cp
Align Code
If you use the align package, just try to align the assignments. Select the whole line (V), and align the code to the = sign.
V \t=
Configuration
By default ":make" runs the make command in the current directory (:pwd). You can change as follows
set makeprg=gmake\ -C\ ~/build/qemu
In fact, you can even set a remote compilation in another machine.
set makeprg=ssh\ mada7\ \"gmake\ -C\ ~/build/qemu\"
Editing
Shortcuts
- :x - Jump to line 'x' in the file
- yxy or xyy - Copy x lines to clipboard
- dxd or xdd - Cut x lines to clipboard
- SHIFT% - Finds a pair. For example, you want to find a match to the currently highlighted bracket.
- SHIFT# - Searches for a word
- gg - Takes you to the top of the page.
- SHIFTg - Takes you to the bottom of the page.
- Substitution
:%s/'x'/'y'/gc - Replace 'x' with 'y' on all lines (%) :15,25s/hello/goodbye/g - Replace 'x' with 'y' from between lines 15 and 25 inclusive :78s/hello/goodbye/g - Replace 'x' with 'y' only on line 78
Options for substitution g Global -- Change every occurrence on a line, not just the first c Confirm -- Ask before making each change
Configuration
Configuration file to have efficient editing.
set nocompatible " Disables troublesome VI compatibilty set title " Sets the title bar to give the filename and path set ruler " Enables the location information in bottom right corner set nowrap " Disables text wrapping set ignorecase " Searches ignore case set wildmenu " Menu for autocomplete of filenames set number " Prints line numbers on left of screen
Color Scheme
Shortcuts
- Change the current colorscheme
:colorscheme schemename
Configuration
- This is a color scheme which I created for myself, but feel free to use it; works best on black backgrounds. ian.vim -- Screenshot -- To install, place the file in your ~/.vim/colors/ directory, (~/.vim/colors/ian.vim), and add the following line to your .vimrc or .gvimrc file
colorscheme ian
- It is possible to set any file to highlight the syntax correctly for any filetype needed, by associating the filetype with a vim syntax file.
- For Ruby Verilog, add the following line to your ~/.vimrc file. This will enable Verilog syntax highlighting in Ruby Verilog files.
au BufNewFile,BufRead *.rv set ft=verilog
- For CUDA Files, you need to do one extra step. You will need to save this CUDA syntax file to your ~/.vim/syntax/ directory, and then add the following two lines to the ~/.vimrc file.
au BufNewFile,BufRead *.cu set ft=cu au BufNewFile,BufRead *.cuh set ft=cu