Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vim [2019/03/31 14:49] 127.0.0.1 external edit |
vim [2019/07/27 16:46] (current) |
||
---|---|---|---|
Line 20: | Line 20: | ||
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 31: | ||
<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 48: | ||
--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 1 | + | sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1 |
- | 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 1 | + | sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1 |
- | 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 95: | ||
// 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 107: | ||
[[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 127: | ||
|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> | ||
+ | |||
+ | ==== Editing Remote Files ==== | ||
+ | |||
+ | To edit a remote file run the following command: | ||
+ | <code bash> | ||
+ | vim scp://[email protected][:port]//path/to/file.txt | ||
</code> | </code> | ||
Line 156: | Line 163: | ||
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 179: | ||
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 202: | ||
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 210: | ||
==== 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 233: | ||
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 244: | ||
- | ===== Vim Operations ===== | + | ===== vim Operations ===== |
==== Exuberant Ctags ==== | ==== Exuberant Ctags ==== | ||
Line 260: | Line 267: | ||
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 273: | ||
==== 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 287: | ||
==== 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 297: | ||
==== Programming ==== | ==== Programming ==== | ||
- | <code Vim> | + | <code vim> |
<leader> r " Toggle true/false | <leader> r " Toggle true/false | ||
</code> | </code> | ||
Line 302: | Line 309: | ||
==== Vidir ==== | ==== Vidir ==== | ||
- | To edit filenames in a dir using Vim, use the linux executable ''%%vidir%%'' from the ''%%moreutils%%'' package. Changes take effect after exiting. | + | 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 328: | Line 335: | ||
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 | ||
- | |||