Posts

Showing posts with the label vim

How to let YouCompleteMe handle c99 project?

Create a .ycm_extra_conf.py file  vim ~/.vim/.ycm_extra_conf.py def Settings( **kwargs ): return { 'flags': [ '-std=gnu99', #'-std=c99', '-x', 'c', #'-std=cpp11', #'-x', 'c++', '-static', '-no-pie', #'-D_POSIX_SOURCE', ], } Add one line in ~/.vimrc vim ~/.vimrc let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py' ​

How to use vim to speed up the Python/Javascript/Golang/Flutter/Kotlin development process

Select code block shift + v shift + } o shift + { d or p or y shift + } and shift + { can get pressed multiple times Comment code block shift + v shift + } o shift + { shift + i // or # esc shift + } and shift + { can get pressed multiple times Select a whole object or function ^^ - start of the line v - start visual mode f - jump to the next search character { - this is the search character % - jump to the closing brackets Select a whole object or function (not perfect Inside of a function: vai Replace text in selected text  shift + v shift + } o shift + { :s/old_text/new_text or ctrl + v shift + } o shift + { k ^^ w or b c ​

How to do the paste without losing the clipboard content in vim

Generally, you use y to copy, p to paste.  But when you select some parts of a text, you hit the p , you’ll lose your clipboard content. (The content would get overridden by your selection. What you could do is to use "0p to do the paste, then if you want to paste it again, you use . ​

How to use vim to speed up the HTML development process

1. select an entire HTML tag and do a copy v at yy 2. go to another end of your HTML tag  v at o ese ​

How to use vim to create a list of numbers that increases

Read from: https://stackoverflow.com/a/48408001/8667243 If you have: 0 0 0 0 You use:  ctrl+v down key g ctrl+a How to reselect a few lines: gv How to move the cursor to the end/start of a visual selection: o/O Here’s another tip for you, if you feel too bored with VIM: https://yingshaoxo.blogspot.com/2019/06/repeat-boring-work-with-vim.html ​

Dive into VIM, part 1

I used to think that I have already mastered VIM. But I was wrong... This is what I have learned today: Repeat actions for selected lines VG to select lines :normal to apply . to each line that you selected Search and Replacement of current word * to search current word caw to delete current word and get into insert mode, c means change (caw: change a word) n. to replace the next matched word Word deletion daw : delete a word dap : delete a paragraph d2w : delete 2 words c2w : delete 2 words and get into insert mode Word case change vaw~ : visualize a word, and change its case. Quick mode change in the insert mode: ctrl+w will delete a word before your cursor back to normal mode: ctrl+[ Copy and paste for a word vawy : visualize a word and copy it vawp : visualize a word and replace it with copied text Get help :help operator will pop up the help document ​

Vim Tips for speeding up the current line editing

^: go to the beginning of that line. g_: go to the end of that line. %: jump between ( and ), or { and }. /,: go to the next ',', press 'n' to go to the next again. (',' can be any symbol) f_: find the next '_', and jump to it. ('_' can be any symbol) W: move to the start of the next word. ('w' and 'e' is also available) B: move back to the start of the previous word. ('b' is also available) dw: delete the current word.

Use VIM in Sublime-Text

1. go the references -> settings 2. add: ``` "ignored_packages": [], "vintage_use_clipboard": true ``` 3. open a text file, press ESC, enjoy!