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/03/10 16:36]
127.0.0.1 external edit
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
Line 5: Line 6:
  
 ===== Installing Vim ===== ===== Installing Vim =====
 +
 Installing Vim with my plugins requires Vim with python. The reason for this is so that YCM works.  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. There is an issue with YCM, Vim and Ubuntu 16.04 which is a conflict between python 2 and 3.
Line 20: Line 22:
     python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev git     python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev git
  
-sudo apt-get remove Vim Vim-runtime gVim Vim-common+sudo apt-get remove vim vim-runtime gvim vim-common
 </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 31: Line 33:
 <code bash> <code bash>
 cd  cd 
-git clone https://github.com/Vim/Vim.git +git clone https://github.com/vim/vim.git 
-cd Vim+cd vim
 git checkout git checkout
  
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
  
-sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/Vim +sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 
-sudo update-alternatives --set editor /usr/local/bin/Vim  +sudo update-alternatives --set editor /usr/local/bin/vim  
-sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/Vim +sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 
-sudo update-alternatives --set vi /usr/local/bin/Vim+sudo update-alternatives --set vi /usr/local/bin/vim
 </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/Vim82 -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 my gitrepo [[https://github.com/paulsammut/paul_scripts/blob/master/install/res/.vimrc|link]].+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:
    
 <code bash> <code bash>
-cd .Vim/bundle/YouCompleteMe +cd .vim/bundle/YouCompleteMe 
 ./install.py --clang-completer ./install.py --clang-completer
 </code> </code>
Line 95: Line 97:
 // List of packages to not update (regexp are supported) // List of packages to not update (regexp are supported)
 Unattended-Upgrade::Package-Blacklist { Unattended-Upgrade::Package-Blacklist {
- "Vim";+ "vim";
 // "libc6"; // "libc6";
 // "libc6-dev"; // "libc6-dev";
Line 107: Line 109:
 [[https://github.com/Valloric/YouCompleteMe/issues/2136|link]]. [[https://github.com/Valloric/YouCompleteMe/issues/2136|link]].
            
-<code Vim>+<code vim>
 :echo has("python"    " this tells you if you have python2 support :echo has("python"    " this tells you if you have python2 support
 :echo has("python3"   " this tells you if you have python3 support :echo has("python3"   " this tells you if you have python3 support
Line 127: Line 129:
 |script-variable|    s:   Local to a |:source|'ed Vim script. |script-variable|    s:   Local to a |:source|'ed Vim script.
 |function-argument|  a:   Function argument (only inside a function). |function-argument|  a:   Function argument (only inside a function).
-|Vim-variable|       v:   Global, predefined by Vim.+|vim-variable|       v:   Global, predefined by Vim.
 </code> </code>
  
 The following command shows you all the variables that are set. The following command shows you all the variables that are set.
-<code Vim>+<code vim>
 :let g: :let g:
 </code> </code>
  
 If you type a variable name after, you will get what it is currently set to.  If you type a variable name after, you will get what it is currently set to. 
-<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 156: Line 187:
 the ''%%.vimrc%%'' file: the ''%%.vimrc%%'' file:
  
-<code Vim+<code vim
-let g:ycm_global_ycm_extra_conf = '~/.Vim/.ycm_extra_conf.py'+let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
 </code> </code>
  
Line 172: Line 203:
 red, and they cover any text making it super annoying. SO. You have to change the red, and they cover any text making it super annoying. SO. You have to change the
 color. THIS IS NOT EASY as there are like a bajillion different colors. There are color. THIS IS NOT EASY as there are like a bajillion different colors. There are
-cterm colors and gui colors. Gui colors are for gVim, which we don't use so don't+cterm colors and gui colors. Gui colors are for gvim, which we don't use so don't
 worry about that. We use cterm colors, and there are ctermfg and ctermbg.  worry about that. We use cterm colors, and there are ctermfg and ctermbg. 
  
 <code> <code>
-gui == gVim.+gui == gvim.
 cterm == terminal. cterm == terminal.
 fg == foreground fg == foreground
Line 195: Line 226:
 So to change the warning highlight color, I would say:  So to change the warning highlight color, I would say: 
  
-<code Vim>+<code vim>
 highlight YcmWarningSection ctermfg=XTERMCOLORNUMBER highlight YcmWarningSection ctermfg=XTERMCOLORNUMBER
 </code> </code>
Line 203: Line 234:
 ==== Command-T ==== ==== Command-T ====
 For the command-t plugin, you need to go to ''%%~/.vim/bundle/command-t%%'' and For the command-t plugin, you need to go to ''%%~/.vim/bundle/command-t%%'' and
-type in ''%%rake make%%''. This is to fix the command-t "Vim could not load the+type in ''%%rake make%%''. This is to fix the command-t "vim could not load the
 c extension" error. c extension" error.
  
Line 226: Line 257:
 brackets. There are lots of ones I use regularly and to refresh do  brackets. There are lots of ones I use regularly and to refresh do 
  
-<code Vim>+<code vim>
 :help unimpared :help unimpared
 </code> </code>
Line 237: Line 268:
  
  
-===== Vim Operations =====+===== vim Operations =====
  
 ==== Exuberant Ctags ==== ==== Exuberant Ctags ====
Line 260: Line 291:
 To search and replace within a visual selection within a line you must use the %V atom. Make a selection and use the following command: To search and replace within a visual selection within a line you must use the %V atom. Make a selection and use the following command:
  
-<code Vim>+<code vim>
 :%s/\%Vselection/replace/g :%s/\%Vselection/replace/g
 </code> </code>
Line 266: Line 297:
 ==== Movement ==== ==== Movement ====
  
-<code Vim>+<code vim>
 ]]  " Jump forward to begin of next toplevel ]]  " Jump forward to begin of next toplevel
 [[  " Jump backwards to begin of current toplevel (if already there, previous toplevel) [[  " Jump backwards to begin of current toplevel (if already there, previous toplevel)
Line 280: Line 311:
 ==== Commenting ==== ==== Commenting ====
  
-I use plugin [[https://github.com/tomtom/tcomment_Vim|tcomment]] for commenting lines. Keybindings are:+I use plugin [[https://github.com/tomtom/tcomment_vim|tcomment]] for commenting lines. Keybindings are:
  
-<code Vim>+<code vim>
 gc{motion}          " Toggle comments  gc{motion}          " Toggle comments 
 gc<Count>c{motion}  " Toggle comment with count argument                    gc<Count>c{motion}  " Toggle comment with count argument                   
Line 290: Line 321:
  
 ==== Programming ==== ==== Programming ====
-<code Vim>+<code vim>
 <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 ===== ===== Programming C/C++ in Vim =====
  
Line 324: Line 363:
  
 Link: [[https://github.com/christoomey/dotfiles/issues/13|Problem]] Link: [[https://github.com/christoomey/dotfiles/issues/13|Problem]]
-Link: [[http://useVim.com/2012/04/18/startuptime/|Helpful]]+Link: [[http://usevim.com/2012/04/18/startuptime/|Helpful]]
  
 Issue is because of xsmp init. Vim is trying to connect Issue is because of xsmp init. Vim is trying to connect
  
-~~DISCUSSION~~ 
  
  • vim.1552235806.txt.gz
  • Last modified: 2019/03/10 16:36
  • by 127.0.0.1