vim notes
While editing a TeX file in vim, jump to the specified chapter
Install unite.vim and unite-outline. Then:Unite outline
Install unite.vim and unite-outline
mkdir /home/hoge/.vim/bundle git clone https://github.com/Shougo/neobundle.vim /home/hoge/.vim/bundle/neobundle.vimThen in vimrc
" Note: Skip initialization for vim-tiny or vim-small. if 0 | endif if &compatible set nocompatible " Be improved endif " Required: set runtimepath+=~/.vim/bundle/neobundle.vim/ " Required: call neobundle#begin(expand('~/.vim/bundle/')) NeoBundle 'Shougo/unite.vim' NeoBundle 'Shougo/unite-outline' " Let NeoBundle manage NeoBundle " Required: NeoBundleFetch 'Shougo/neobundle.vim' " My Bundles here: " Refer to |:NeoBundle-examples|. " Note: You don't set neobundle setting in .gvimrc! call neobundle#end() " Required: filetype plugin indent on " If there are uninstalled bundles found on startup, " this will conveniently prompt you to install them. NeoBundleCheckand start up vim, it will ask if you want to install unite.vim and unite-outline. Note that it takes a little time to install.
Unite outline buffer always displayed
:Unite -winheight=15 -no-quit outlineFor vertical split
:Unite -vertical -winwidth=30 -no-quit outline
Despite setting
set tw=0in vimrc, it is not reflected at all. At any rate, it is very annoying when writing Intel Fortran90 programs.
A new superfluous meddling that appeared in vim installed in Ubuntu16.04.
For Fortran90, you can create fortran.vim in .vim/after/ftplugin/ and useset tw=0in it. Also
:verbose set textwidthwill tell you which file is the culprit. I do not use it anymore, but if you are messing with fixed format files
if (b:fortran_fixed_source == 1) setlocal comments=:!,:*,:C setlocal tw=72 else setlocal comments=:! setlocal tw=0 endif
Indented when typing certain characters or strings.
A very superfluous intervention. It cannot be disabled withset noautoindent set nosmartindent
:set indentkeyswill tell you which strings are indented when typed. To disable it, use
:set indentkeys=This is also not enabled by writing in vimrc. Therefor,
:verbose set indentkeyswill identify the culprit file and create a file in .vim/after/indent/ that will disable it (for example, for a TeX file, in tex.vim,
set indentkeys=) . However, this will not indent everything. For example, if you want to indent only newlines, you can use
set indentkeys=<Return>It seems that you can set various indentation methods, but personally, I do not need indentation except for newlines, so this is sufficient.
Automatically turn off Fcitx when returning from insert mode to normal mode.
There is a useful plugin available, so use it. installed using NeoBundle. Specifically, just addNeoBundle 'vim-scripts/fcitx.vim'to the part of vimrc you wrote when you installed unite-vim.
I'm a whitespace person, not a tab person, so in vimrc
set tabstop=2 set expandtab set shiftwidth=2number is number of spaces when indented.
Selecting a range in Vim, GVim results in selecting the entire line containing that range.
I still have not found a solution. Because of this:s/./&/gnI cannot do character counts using and it also replaces things I do not want replaced.
Character count in Vim, GVim
g Ctrl-g
Prevent indentation when pasting copied instead of yanked in vim
:set paste
Move vim cursor by display line
vimrcにてnnoremap j gj nnoremap k gk nnoremap <Down> gj nnoremap <Up> gkOnly valid in normal mode. Cannot be used in insert mode.
Move between end of previous line and beginning of next line
In vimrcset whichwrap=b,s,<,>,[,]
Update diff view with vimdiff
:diffupdate
Differential display mode in gvim
:vertical diffsplit filename
Moving to the current directory with gvim
:set autochdir
This is not reflacted even though set autochdir is specified in vimrc in gvim
vimrcにcd %:hSince autochdir is applied by default in vim and gvim installed on Ubuntu 16.04, these measures are no longer necessary.
Search for newline and replace with newline in vim
Example (replace newline with hoge newline):%s/\n/hoge^M/gc^M can be called by pressing Ctrl+v then Enter
Buffer Handling
Displaying Buffers:lsGo to specified buffer
:b numberGo to next buffer
:bnGo to previous buffer
:bp
Character encoding related
vim character encoding check:set enc?file character encoding check
:set fenc?specify encoding and save again
:set fenc=character codespecify character code and read again
:e ++enc=character code
Spell check by set spell does not work while editing TeX files.
Create a file named after/syntax/tex.vim in the .vim directorysyntax spell toplevel
Replace part of the searched string
For example, if you want to replace [1] or [2] with [[01]] or [[02]] (but not the numbers 1 or 2), use the hold buffer:s/[\(.\)]/[[0\1]]/gIn other words, enclose the part you do not want to replace with¥(and ¥) and call it with ¥1 for the converted part. You can specify multiple hold buffers and call them from ¥1 to ¥.
I often forget about mobile systems, so link (Jpn)
Make JupyterLab a vim specification
pip install jupyterlab-vim