Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vim [2019/02/27 21:10] paul [Compiling] |
vim [2020/10/19 17:24] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Vim ====== | ====== Vim ====== | ||
+ | |||
Vim is one of my favorite tools. Whenever you are working and think, hey it | Vim is one of my favorite tools. Whenever you are working and think, hey it | ||
would be really useful if I could do this, chances are Vim lets you do just that | would be really useful if I could do this, chances are Vim lets you do just that | ||
in a couple of keystrokes. | in a couple of keystrokes. | ||
- | ===== Installing | + | ===== Installing |
- | Installing | + | |
- | There is an issue with YCM, VIM and Ubuntu 16.04 which is a conflict between python 2 and 3. | + | Installing |
- | What we do is pic vim to compile with python2 and set YCM to also compile with just python2. | + | There is an issue with YCM, Vim and Ubuntu 16.04 which is a conflict between python 2 and 3. |
- | We then have to run an install script which makes it work. Also, this compilation of VIM | + | What we do is configure Vim to compile with python2 and set YCM to also compile with just python2. |
+ | We then have to run an install script which makes it work. Also, this compilation of Vim | ||
gives us the awesome clipboard support that works right out of the box. We also | gives us the awesome clipboard support that works right out of the box. We also | ||
install ruby for the fantastic Command-T plugin to work. | install ruby for the fantastic Command-T plugin to work. | ||
- | Follow this to compile | + | Follow this to compile |
<code bash> | <code bash> | ||
Line 23: | Line 25: | ||
</ | </ | ||
- | Make sure vim is removed! When you type vim you should see nothing | + | Make sure Vim is removed! When you type vim you should see nothing |
==== Compiling ==== | ==== Compiling ==== | ||
Line 48: | Line 50: | ||
| | ||
- | make VIMRUNTIMEDIR=/ | + | make vimRUNTIMEDIR=/ |
sudo apt install checkinstall | sudo apt install checkinstall | ||
sudo checkinstall | sudo checkinstall | ||
Line 58: | Line 60: | ||
</ | </ | ||
- | Be sure to change the version when executing the make command. For instance, if the major vim version is at 8.2, then make line should be: | + | Be sure to change the version when executing the make command. For instance, if the major Vim version is at 8.2, then make line should be: |
<code bash> | <code bash> | ||
- | make VIMRUNTIMEDIR=/ | + | make vimRUNTIMEDIR=/ |
</ | </ | ||
Then grab the Vundle plugin manager. | Then grab the Vundle plugin manager. | ||
<code bash> | <code bash> | ||
- | git clone https:// | + | git clone https:// |
</ | </ | ||
- | Get the .vimrc file from git. | + | Get the '' |
- | Run vim and use command <code vim>: | + | Run Vim and use command <code vim>: |
YouCompleteMe requires a bit more processing to install: | YouCompleteMe requires a bit more processing to install: | ||
Line 84: | Line 86: | ||
</ | </ | ||
- | Also disable the unattended updates. If you do not do this, every day vim will get | + | Also disable the unattended updates. If you do not do this, every day Vim will get |
- | downgraded to 7.4.1689. To do this, add vim to the black list, by editing: | + | downgraded to 7.4.1689. To do this, add Vim to the black list, by editing: |
<code bash> | <code bash> | ||
Line 102: | Line 104: | ||
</ | </ | ||
- | ===== Notes ===== | + | ===== General |
Discussion on the python issue with YCM and Vim | Discussion on the python issue with YCM and Vim | ||
- | [[https:// | + | [[https:// |
<code vim> | <code vim> | ||
Line 113: | Line 115: | ||
</ | </ | ||
- | If vim looks like it freezes inside tmux, it's because I accidentally pressed <C-s> | + | If Vim looks like it freezes inside tmux, it's because I accidentally pressed <C-s> |
which disables flow control in the terminal. Just hit <C-q> and everything will be | which disables flow control in the terminal. Just hit <C-q> and everything will be | ||
alright. | alright. | ||
- | There are things called internal-variables in vim. | + | There are things called internal-variables in Vim. |
< | < | ||
Line 138: | Line 140: | ||
<code vim> | <code vim> | ||
:let g: | :let g: | ||
+ | </ | ||
+ | |||
+ | To go to a tab, do '' | ||
+ | |||
+ | Send one command while in insert mode: '' | ||
+ | |||
+ | Open a link in mac with the cursor on it: '' | ||
+ | |||
+ | ===== Snippets ===== | ||
+ | |||
+ | To use snippets for repetive code, put that code in a folder. Then use the '' | ||
+ | ./ | ||
+ | Pease! | ||
+ | |||
+ | ==== Editing Remote Files ==== | ||
+ | |||
+ | To edit a remote file run the following command: | ||
+ | <code bash> | ||
+ | vim scp:// | ||
</ | </ | ||
===== Plugins ===== | ===== Plugins ===== | ||
+ | |||
The following is info on the plugins I use. | The following is info on the plugins I use. | ||
+ | ==== Airline ==== | ||
+ | |||
+ | It took me so long to figure this stupid plugin out. It doesn' | ||
+ | |||
+ | === For MacOS === | ||
+ | |||
+ | Install the patched font, then select the font in terminal. | ||
+ | |||
+ | {{: | ||
==== NerdTree ==== | ==== NerdTree ==== | ||
Line 154: | Line 185: | ||
YCM uses a python script to tell it what to do in terms of syntax highlighting and | YCM uses a python script to tell it what to do in terms of syntax highlighting and | ||
error/ | error/ | ||
- | the .vimrc file: | + | the '' |
<code vim> | <code vim> | ||
Line 160: | Line 191: | ||
</ | </ | ||
- | There is a good write up about this [[https:// | + | This is a good write up about YCM [[https:// |
- | I used this .ycm_extra_conf.py file because it had the new -std flags and didn't give | + | I used this '' |
me a stupid warning that obscures | me a stupid warning that obscures | ||
- | everything((https:// | + | everything ((https:// |
Line 184: | Line 215: | ||
You can also style the line that has the warning/ | You can also style the line that has the warning/ | ||
- | *YcmErrorLine*, which falls back to group SyntasticErrorLine if it exists | + | '' |
- | *YcmWarningLine*, which falls back to group SyntasticWarningLine if it exists | + | '' |
Note that the line highlighting groups only work when gutter signs are turned on. | Note that the line highlighting groups only work when gutter signs are turned on. | ||
The syntax groups used to highlight regions of text with errors/ | The syntax groups used to highlight regions of text with errors/ | ||
- | *YcmErrorSection*, which falls back to group SyntasticError if it exists and then SpellBad | + | '' |
- | *YcmWarningSection*, which falls back to group SyntasticWarning if it exists and then SpellCap | + | '' |
- | So to change the warning highlight color, | + | So to change the warning highlight color, |
<code vim> | <code vim> | ||
Line 202: | Line 233: | ||
==== Command-T ==== | ==== Command-T ==== | ||
- | For the command-t plugin, you need to go to ~/ | + | For the command-t plugin, you need to go to '' |
- | is to fix the command-t "vim could not load the c extension" | + | type in '' |
+ | c extension" | ||
- | The [[https:// | + | The documenation here has a great how-to section |
- | here has a great how to section]]. | + | |
< | < | ||
Line 237: | Line 268: | ||
- | ===== Vim Operations ===== | + | ===== vim Operations ===== |
==== Exuberant Ctags ==== | ==== Exuberant Ctags ==== | ||
Line 254: | Line 285: | ||
</ | </ | ||
- | Then in vim just go over any text you want and press <C-]> to go to the token. | + | Then in Vim just go over any text you want and press <C-]> to go to the token. |
==== General Operations ==== | ==== General Operations ==== | ||
Line 293: | Line 324: | ||
< | < | ||
</ | </ | ||
+ | |||
+ | ==== Ordered Number List ==== | ||
+ | |||
+ | Make a list of 1's, then block select the second one, and then press g < | ||
==== Quickfix ==== | ==== Quickfix ==== | ||
Line 299: | Line 334: | ||
To navigate to the quick fix, <C-w> j. | To navigate to the quick fix, <C-w> j. | ||
+ | |||
+ | ==== Vidir ==== | ||
+ | |||
+ | To edit filenames in a directory using Vim, use the linux executable '' | ||
+ | ===== Programming C/C++ in Vim ===== | ||
+ | |||
+ | I use YCM and ctags extensively while coding in C/C++. | ||
+ | |||
+ | === Vim Shortcuts === | ||
+ | < | ||
+ | |||
+ | <C-w> gf Opens file under cursor in new tab | ||
+ | |||
+ | K Get documentation info pop up its man page. | ||
+ | |||
+ | [i Pressing on a function gives its signature. | ||
+ | </ | ||
+ | |||
+ | ==== File Management ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
- | If VIM is slow in tmux: | + | If Vim is slow in tmux: |
Link: [[https:// | Link: [[https:// |