如何阻止Vim在80个字符后换行

4

我正在使用vim作为Python IDE以及Octopress的一些Markdown编辑器。它在每80个字符处创建一个新行。我想要关闭这个功能(启用单词换行),这样典型文本文件的编辑就不会那么痛苦了。

这是我的.vim配置:

filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()

set foldmethod=indent
set foldlevel=99

map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h

map <leader>td <Plug>TaskList

map <leader>g :GundoToggle<CR>

syntax on                           " syntax highlighing
filetype on                          " try to detect filetypes
filetype plugin indent on    " enable loading indent file for filetype

let g:pyflakes_use_quickfix = 0

let g:pep8_map='<leader>8'

au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"

set number
set completeopt=menuone,longest,preview

set autochdir
let NERDTreeChDirMode=2
map <leader>n :NERDTreeToggle<CR>

map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>

nmap <leader>a <Esc>:Ack!

set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v][%{fugitive#statusline()}]

map <leader>dt :set makeprg=python\ manage.py\ test\|:call MakeGreen()<CR>

" Execute the tests
nmap <silent><Leader>tf <Esc>:Pytest file<CR>
nmap <silent><Leader>tc <Esc>:Pytest class<CR>
nmap <silent><Leader>tm <Esc>:Pytest method<CR>
" cycle through test errors
nmap <silent><Leader>tn <Esc>:Pytest next<CR>
nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
nmap <silent><Leader>te <Esc>:Pytest error<CR>

" Add the virtualenv's site-packages to vim path
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
   execfile(activate_this, dict(__file__=activate_this))

EOF

set background=dark
colorscheme molokai
set spell
set textwidth=0 wrapmargin=0

" Auto-close brackets
inoremap {      {}<Left>
inoremap {<CR>  {<CR>}<Esc>O
inoremap {{     {
inoremap {}     {}
inoremap (  ()<Left>
inoremap ()     ()
inoremap ((     (
inoremap <  <><Left>
inoremap <<     <
inoremap <>     <>

有什么想法吗?
2个回答

7

我相信这是您想要的:在Vim中实现单词换行而不产生断行

相关部分:将以下设置添加到您的配置文件中:

set wrap
set linebreak
set nolist  " list disables linebreak

这将在视觉上换行,但直到您明确按下“Enter”键才会插入换行符。

编辑:根据评论,添加以下行也是一个好主意:

set textwidth=0

您还需要根据链接将textwidth设置为0。这是默认设置,但如果OP遇到了换行问题,那么他可能已经进行了设置。 - Conner

4
您只需设置textwidth和wrap即可:
您只需要设置textwidth和wrap即可:
set textwidth=0
set wrap

set textwidth=0 对我很有帮助。 - HugoTai

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接