Content #
:execute "normal! mqA;\<esc>`q"
“mq”: store the current location in mark “q”.
“\<esc>”: a string escape sequence which resolves to a press of the escape key.
From #
Links #
:help expr-quote
:set textwidth=80
:echo &textwidth
布尔值会以0和非0来表示。
:set nowrap
:echo &wrap
Vim displays 0.
:let &textwidth=100
:set textwidth?
使用let的形式来设置option的好处在于可以使用vimscript的全部功能:
:let &textwidth = &textwidth + 10
set则只能将其设置为固定的值。
:let &l:number = 1
Markdown文件的标题格式如下:
Topic One
=========
some text about topic one.
it has multiple paragraphs.
Topic Two
=========
some text about topic two.
after the last.
inside section’s heading:
:onoremap ih :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rkvg_"<cr>
around section’s heading:
:onoremap ah :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rg_vk0"<cr>
Vim中下面两个Mark的含义有何区别?
`^
`.
`^ To the position where the cursor was the last time when Insert mode was stopped.
`. To the position where the last change was made. The position is at or near where the change started.
前者针对的Insert mode的切换,后者针对的是文本的变化。像x,p等命令会改变文本,但不涉及Insert mode的切换。
前者可用gi命令来操作,后者由g;命令来操作。