Thursday, June 13, 2013

VIM Tips


Tips:
-plugins
matchit.vim
zenburn color scheme

-filetype detection for verilog and systemverilog
download systemverilog.vim plugin


-profile vim load time, for debugging slowness opening file
    Profiling Vim
- map CapsLock key to Contrl, and use "ctrl+[" for escaping
-vimdiff:
    vim -d file1 file2
    :diffthis
    :diffoff
    do #diff obtain from the other file
    dp #diff put current code to the other file
Plugin:

- File Finder: MRU.vim, and ctrlp.vim

- Colorschem: Zenburn.vim (by the way, zenburn your gnome terminal: http://ubuntuforums.org/showthread.php?t=1091337 however, you need to change the pallete to this value: #3F3F3F3F3F3F:#CCCC93939393:#7F7F9F9F7F7F:#E3E3CECEABAB:#DFDFAFAF8F8F:#CCCC93939393:#8C8CD0D0D3D3:#DCDCDCDCCCCC:#3F3F3F3F3F3F:#CCCC93939393:#7F7F9F9F7F7F:#E3E3CECEABAB:#DFDFAFAF8F8F:#CCCC93939393:#8C8CD0D0D3D3:#DCDCDCDCCCCC)

- Matchit.vim: need to set for non standard filetypes like systemverilog, see My VIM Settings.
UPDATE: this is a great plug-in for finding a file if you know part of its names. however, since then, i have replaced it with ctags which removs the need to find a file. You should try catags too.

show invisible characters:
http://vimcasts.org/episodes/show-invisibles/

-Backspace does not delete to the left, delete forward. vim key mapping issues. fix in .vimrc with mapping.
backspace deletes characters forward like the delete key in vim when using term=xterm #641

-increment/decrement numbers
  • Ctrl+a will increment the number under the cursor or the first occurrence of a number to the right of the cursor
  • Ctrl+x will decrement the number under the cursor or the first occurrence of a number to the right of the cursor

You can also provide a count prefix:

  • 3 followed by Ctrl+a will add 3
  • 1000 followed by Ctrl+x will subtract 1000

-substitute within visual selection
    do visual selection, then substitute with command :%s/\%VPATTERN/REPLACEPATTERN/g
    NOTE: this works for block selection too!

-some filetype plugins can overwrite some vim settings, as these are loaded last, so setting it in vimrc wont work. and as these may be system level plugin and you may not have permission to modify. to workaround this, you can have an appropriate autocommand in your vimrc. 
    au   FileType systemverilog  set textwidth=0

No comments:

Post a Comment

C Programming

Header Files and Includes https://cplusplus.com/forum/articles/10627/ https://stackoverflow.com/questions/2762568/c-c-include-header-file-or...