[2] vimawesome.com vim plugin\
[3] linux.com vim-101-a-beginners-guide-to-vim
[4] derickbailey/2010/04/23/using-vim-as-your-c-code-editor-from-visual-studio/
[5] cscope.sourceforge.net/cscope_vim_tutorial.html
qyang@lubuntu-laptop:~$ tree ~/.vim
/home/qyang/.vim
├── autoload
│ ├── acp.vim
│ └── tagbar.vim
├── doc
│ ├── acp.jax
│ ├── acp.txt
│ ├── tagbar.txt
│ ├── tags
│ └── tags-ja
├── plugin
│ ├── cscope_maps.vim
│ └── tagbar.vim
├── plugins
│ ├── acp.vim
│ ├── cctree.vim
│ ├── ming.vim
│ └── qt.vim
├── README.md
└── syntax
├── python.vim
└── tagbar.vim
ming.vim
qt.vim
------------------------------------
: colorscheme morning : syntax on : autocmd FileType * set formatoptions=tcql nocindent comments& : autocmd InsertEnter * colorscheme blue : autocmd InsertLeave * colorscheme morning : set autowrite : ab #d #define : ab #i #include : ab #b /******************************************************** : ab #e ^H^H********************************************************/ : ab #l /*------------------------------------------------------*/ : set sw=4 : set notextmode : set notextauto : set hlsearch : set incsearch : set textwidth=150 : au BufWinEnter * let w:m1=matchadd('Search','\%<151v .="">77v', -1) : au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>150v.\+', -1) : autocmd FileType c,cpp set formatoptions=croql cindent comments=sr: /*,mb: *.ex: */,: // : set nowrap : match ErrorMsg '\%>80v.\+' : set expandtab : set shiftwidth=2 : set softtabstop=2 : map: s/^/\/\// 151v>: map : s/^\/\/// : set smartcase : set ic
: nmap :TagbarToggle func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py : call DeleteTrailingWS()
Generate cscope.out on root directory of source code project, then start vim from that root directory. All symbols index in cscope.out can be used by vim now.
Try below to jump straight to the file including 'main' symbol
$vi -t main
Insert following code into makefile to generate cscope.out via make.
$make cscope -f MakefileName
# Make software # # Generate csope files cscope: cscope.out cscope.out: cscope.files @cscope -R -b -i $< cscope.files: @find am335x -name "*.[ch]" -not -path "*/bootloader/*" > $@ && \ find libs -name "*.[ch]" -not -path "*/kissfft/*" >> $@ && \ find am335x -name "*.cpp" -o -name "*.h" -not -path "*/bootloader/*" >> find rtos -name "*.c" -o -name "*.h" -o -name "*.cpp" >> $@ clean: @rm cscope.*
DISPLAY TAB
---------------------
Not quite work correctly to show all tabs
:SeeTab vim.wikia.com
OPEN MULTIPLE FILES FROM CMD LINE
-------------------------
qyang@lubuntu-laptop:~/Git_Local_Sandbox/PcapPlot$ vi -g -p *.sh *.py 12 files to edit
TURN ON LINE NUMBER
------------------------
:set number
REPLACE A STRING
-------------------
:1,$s/word1/word2/gc IN A WHOLE FILE
:n1,n2s/word1/word2/gc IN BETWEEN LINE 'n1' and 'n2', special character use '\' prefix. (e.g.,:1,$s/word\[/word1\[/gc, replace 'word[' with 'word1[' )
COMMAND MODE
---------------------
'g0' -- go zero, go to head of line;
'g$' -- go to end of line;
'G' -- go to end of this file;
'H' -- go to top of screen;
'M' -- go to middle of screen;
'L' -- go to bottom of screen;
'nG' -- go to line number 'n'
'/word' -- search a string 'word' forward;
'?word' -- search a string 'word' backward;
'nyy' -- yank/copy n lines after cursor;
'p' -- paste yanked contens one line below cursor;
'dd' -- delete current line;
'nd' -- delete n lines after cursor;
DELETE/COPY(YANK) A BLOCK OF TEXT
----------------------------
The ‘mark command can be very useful when deleting a long series of lines.To
delete a long series of lines, follow these steps:
1. Move the cursor to the beginning of the text you want to delete.
2. Mark it using the command ma. (This marks it with mark a.)
3. Go to the end of the text to be removed. Delete to mark a using the command
d’a.
Note:There is nothing special about using the a mark. Any mark from a to z
may be used.
BACK TO PREVIOUSLY VISITED LOCATION previous view
-----------------------------
Ctrl + O
Ctrl + I (tab)
Jumping_to_previously_visited_locations
JUMP TO SYMBOL DEFINITION when ctags/cscope enabled
------------------------------
Ctrl + ]
Ctrl + T
A 05 Vi Exercise
===============================
[1] http://stackoverflow.com/questions/1737163/traversing-text-in-insert-mode
Insert mode and navigation mode switch
----------------------------------------
ESC or Ctrl+[
Navigation Fast
--------------------
15 + h go backward 15 characters
5 + j go forward 5 lines
Ctrl+o + 2 + b navigate two words back without leaving insert mode
Ctrl+o will give you chance to run one vi command at navigation
mode, then return to insert mode automatically.
'+. back to previous editing place after navigation
Type 20 '-' delete backword 9 '-'
----------------------------------------
20 + i + - + ESC
9 + X
'20' set number of execute times
'i' into insert mode
'-' letter or words you want to repeat
'ESC' back to navigation mode will display all insert letters.
'9' set number of exectue times
'X' delete backward, 'x' delete forward
Paste from clip board
-----------------------------------
"+p
" use register
+ clipboard register index
p paste shortcut key
Corret Typo
----------------------
accifently
FfrdA will correct the word from accifently to accidently
'F' find backward 'f' find forward
'f' find letter 'f'
'r' replace current cursor
'd' type correct letter 'd'
'A' back to original edit place
Rewrite word
--------------------
you accidentlly typed
you intentially typed
you intertially typed
ESC + 2 + b + c + w intentially + ESC + A
Write words in multiple lines
--------------------
[2] http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
hello
hello
hello
hel:added:loappend
hel:added:loappend
hel:added:loappend
hllo hello append
hllo hello append
hllo hello append
Ctrl+v + navigate coursor to 'l' + j + j + j + I + :added: + ESC
Ctrl+v + navigate coursor to 'o' + l + A + Ctrl+R + "
Ctrl+v + select block you want to delete + d
'Ctrl+v' visual block mode.
'I' insert before current cursor in visual block mode.
'A' append after current cursor in visual block mode.
'Ctrl + R + "' past yank register in insert mode
'Ctrl + R + +' past clipboard insert mode.
No comments:
Post a Comment