Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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 VIM ===== +===== Installing Vim ===== 
-Installing vim with my plugins requires Vim with python. The reason for this is so that YCM works.  + 
-There is an issue with YCM, VIM and Ubuntu 16.04 which is a conflict between python 2 and 3. +Installing Vim with my plugins requires Vim with python. The reason for this is so that YCM works.  
-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 VIM:+Follow this to compile Vim:
  
 <code bash> <code bash>
Line 23: Line 25:
 </code> </code>
  
-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:
      --prefix=/usr/local      --prefix=/usr/local
            
-make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 -j8+make vimRUNTIMEDIR=/usr/local/share/vim/vim81 -j8
 sudo apt install checkinstall sudo apt install checkinstall
 sudo checkinstall sudo checkinstall
Line 58: Line 60:
 </code> </code>
  
-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=/usr/local/share/vim/vim81 -j8+make vimRUNTIMEDIR=/usr/local/share/vim/vim82 -j8
 </code> </code>
  
 Then grab the Vundle plugin manager. Then grab the Vundle plugin manager.
 <code bash> <code bash>
-git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim+git clone https://github.com/Vundlevim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
 </code> </code>
  
-Get the .vimrc file from git.+Get the ''%%.vimrc%%'' file from my git repo [[https://github.com/paulsammut/paul_scripts/blob/master/install/res/.vimrc|link]].
  
-Run vim and use command <code vim>:PluginInstall</code> +Run Vim and use command <code vim>:PluginInstall</code> 
  
 YouCompleteMe requires a bit more processing to install: YouCompleteMe requires a bit more processing to install:
Line 84: Line 86:
 </code> </code>
  
-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:
 </code> </code>
            
-===== Notes =====+===== General Notes =====
  
 Discussion on the python issue with YCM and Vim Discussion on the python issue with YCM and Vim
-[[https://github.com/Valloric/YouCompleteMe/issues/2136|here]].+[[https://github.com/Valloric/YouCompleteMe/issues/2136|link]].
            
 <code vim> <code vim>
Line 113: Line 115:
 </code> </code>
  
-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
  
 <code> <code>
Line 138: Line 140:
 <code vim> <code vim>
 :let g:CommandTTraverseSCM :let g:CommandTTraverseSCM
 +</code>
 +
 +To go to a tab, do ''{count}gt'' where count is the tab number (first is one).
 +
 +Send one command while in insert mode: ''CTRL-O''
 +
 +Open a link in mac with the cursor on it: ''gx .''
 +
 +===== Snippets =====
 +
 +To use snippets for repetive code, put that code in a folder. Then use the ''r:
 +./location/of/snippet'' command to dump the text in the active buffer. Easy
 +Pease!
 +
 +==== Editing Remote Files ====
 +
 +To edit a remote file run the following command:
 +<code bash>
 +vim scp://user@myserver[:port]//path/to/file.txt
 </code> </code>
  
 ===== 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't work out of the box. You need to dig through all kinds of documentation.
 +
 +=== For MacOS ===
 +
 +Install the patched font, then select the font in terminal.
 +
 +{{:screen_shot_2019-12-26_at_9.45.42_pm.png?400|}}
 ==== 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/warning display. You have to tell it where to use this script by adding this in error/warning display. You have to tell it where to use this script by adding this in
-the .vimrc file:+the ''%%.vimrc%%'' file:
  
 <code vim> <code vim>
Line 160: Line 191:
 </code> </code>
  
-There is a good write up about this [[https://jonasdevlieghere.com/a-better-youcompleteme-config/|here.]]+This is a good write up about YCM [[https://jonasdevlieghere.com/a-better-youcompleteme-config/|link]]
  
-I used this .ycm_extra_conf.py file because it had the new -std flags and didn't give+I used this ''%%.ycm_extra_conf.py%%'' file because it had the new ''%%-std%%'' flags and didn't give
 me a stupid warning that obscures me a stupid warning that obscures
-everything((https://github.com/arximboldi/dotfiles/blob/master/emacs/.ycm_extra_conf.py)).+everything ((https://github.com/arximboldi/dotfiles/blob/master/emacs/.ycm_extra_conf.py)).
  
  
Line 184: Line 215:
 You can also style the line that has the warning/error with these groups: You can also style the line that has the warning/error with these groups:
  
-*YcmErrorLine*, which falls back to group SyntasticErrorLine if it exists +''%%YcmErrorLine%%'' which falls back to group SyntasticErrorLine if it exists 
-*YcmWarningLine*, which falls back to group SyntasticWarningLine 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/warnings: The syntax groups used to highlight regions of text with errors/warnings:
  
-*YcmErrorSection*, which falls back to group SyntasticError if it exists and then SpellBad +''%%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+''%%YcmWarningSection%%'' which falls back to group SyntasticWarning if it exists and then SpellCap
  
-So to change the warning highlight color, would say: +So to change the warning highlight color, would say: 
  
 <code vim> <code vim>
Line 202: Line 233:
  
 ==== Command-T ==== ==== Command-T ====
-For the command-t plugin, you need to go to ~/.vim/bundle/command-t and type in rake make. This +For the command-t plugin, you need to go to ''%%~/.vim/bundle/command-t%%'' and 
-is to fix the command-t "vim could not load the c extension" error.+type in ''%%rake make%%''. This is to fix the command-t "vim could not load the 
 +c extension" error.
  
-The [[https://github.com/wincent/command-t/blob/master/doc/command-t.txt|documenation +The documenation here has a great how-to section [[https://github.com/wincent/command-t/blob/master/doc/command-t.txt|link]]. 
-here has a great how to section]]. +
  
 <code> <code>
Line 237: Line 268:
  
  
-===== Vim Operations =====+===== vim Operations =====
  
 ==== Exuberant Ctags ==== ==== Exuberant Ctags ====
Line 254: Line 285:
 </code> </code>
  
-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:
 <leader> r          " Toggle true/false <leader> r          " Toggle true/false
 </code> </code>
 +
 +==== Ordered Number List ====
 +
 +Make a list of 1's, then block select the second one, and then press g <cnrl-a>.
  
 ==== 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 ''%%vidir%%'' from the ''%%moreutils%%'' package. Changes take effect after exiting.
 +===== Programming C/C++ in Vim =====
 +
 +I use YCM and ctags extensively while coding in C/C++.
 +
 +=== Vim Shortcuts ===
 +<code>
 +
 +<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.
 +</code>
 +
 +==== File Management ====
 +
 +''%%:checkpath%%''  shows you a list of included files not found in the path.
 +
 +''%%$locate [header]%%''  gives you the location of the system header file.
 +
 ===== Troubleshooting ===== ===== Troubleshooting =====
  
-If VIM is slow in tmux:+If Vim is slow in tmux:
  
 Link: [[https://github.com/christoomey/dotfiles/issues/13|Problem]] Link: [[https://github.com/christoomey/dotfiles/issues/13|Problem]]
  • vim.1551301841.txt.gz
  • Last modified: 2019/02/27 21:10
  • by paul